Query the Query Results
Posted: Mon Nov 13, 2006 9:23 am
Hello,
I've queried a MySql database & displayed the query results succesfully using the code below. I now want to select certain records only by ticking a checkbox next to the query results & re-query these selected records. How do I do that? Thanks for your help. My code is below:-
I've queried a MySql database & displayed the query results succesfully using the code below. I now want to select certain records only by ticking a checkbox next to the query results & re-query these selected records. How do I do that? Thanks for your help. My code is below:-
Code: Select all
<?php
$query2=("SELECT * FROM table");
$result2=mysql_query($query2);
?>
<table width=700 border=1 height="0" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0"><tr bgcolor ="cyan">
<td width="375" align="center" bgcolor="#CCFFFF"><b><font face="arial" size="2.5">Raw Data</a></font></strong></td>
<td width="60" align="center" bgcolor="#CCFFFF"><b><font face="arial" size="2.5">Size</font></strong></td>
<td width="60" align="center" bgcolor="#CCFFFF"><b><font face="arial" size="2.5">Price</font></strong></td>
<td width="80" align="center" bgcolor="#CCFFFF"><b><font face="arial" size="2.5">Untick Bad Data</font></strong></td>
</tr>
<?php
//the code below is to display the results in multi colours
$color="1";
while($rows=@mysql_fetch_array($result2)){
if($color==1){
echo "<tr bgcolor='#CCFFFF'>
<td align=left><font face=arial size=1.5>{$rows['full_add']}</td></font>
<td align=center><font face=arial size=1.5>{$rows['size']}</td></font>
<td align=center><font face=arial size=1.5>{$rows['price']}</td></font>
<td align=center><input type='checkbox' name='C1' value='ON' checked></td></font>
</tr>";
// Set $color==2, for switching to other color
$color="2";
}
// When $color not equal 1, use this table row color
else {
echo "<tr bgcolor='#FFFFFF'>
<td align=left><font face=arial size=1.5>{$rows['full_add']}</td></font>
<td align=center><font face=arial size=1.5>{$rows['size']}</td></font>
<td align=center><font face=arial size=1.5>{$rows['price']}</td></font>
<td align=center><input type='checkbox' name='C1' value='ON' checked></td></font>
</tr>";
// Set $color back to 1
$color="1";
}
}
echo '</table>';
?>