help filtering data with checkboxes
Posted: Sun Jun 26, 2005 11:12 pm
Hello,
I first will say that I am pretty new to PHP. I am working on a project for a website that has records that are entered in to a DB the records are then displayed in a page that shows a preview. IE, you see the address, value, # of bedrooms etc.. You can click a link and it will display details..nothing tough there..
Here is the hard part.. I need to find how to filter these records with checkboxes (next to each DB record ie. 1 main street, 2 main street etc..) when the user clicks a form button so that the other non-selected records disappear. I've figured out how to put the form button and make a new check box on each line but I cannot figure out a way to sort the data.
I have tried several ways including making the form go to a 2nd page which would only show the data that was checked but I cannot figure out how to make that work nor can I figure out how to do it with just one page.
I am really deserpate for an answer because I am really stuck on this and would like to get it done as soon as possible.
Below is the code for the site, the way I have it now it goes to a 2nd page but that is not required, I just assume that will be easiest.
Any suggestions on what to do? Thanks in advance!
That is the HTML part with the form.. below is the coding..
Once again, any help would be great, thanks!
d11wtq | Like the man himself says - we have
I first will say that I am pretty new to PHP. I am working on a project for a website that has records that are entered in to a DB the records are then displayed in a page that shows a preview. IE, you see the address, value, # of bedrooms etc.. You can click a link and it will display details..nothing tough there..
Here is the hard part.. I need to find how to filter these records with checkboxes (next to each DB record ie. 1 main street, 2 main street etc..) when the user clicks a form button so that the other non-selected records disappear. I've figured out how to put the form button and make a new check box on each line but I cannot figure out a way to sort the data.
I have tried several ways including making the form go to a 2nd page which would only show the data that was checked but I cannot figure out how to make that work nor can I figure out how to do it with just one page.
I am really deserpate for an answer because I am really stuck on this and would like to get it done as soon as possible.
Below is the code for the site, the way I have it now it goes to a 2nd page but that is not required, I just assume that will be easiest.
Any suggestions on what to do? Thanks in advance!
Code: Select all
<title>Portfolio Listings</title>
<table width="690" cellspacing="0" cellpadding="3" border="0" style="font-family: sans-serif; font-size: 9pt" align="center">
<!--DWLayoutTable-->
<tr>
<td width="31" height="21" valign="top"><div align="center"><strong>View</strong></div>
</td>
<td width="139" align="center" valign="top" nowrap><div align="center"><a href="../../portfolio/list.php?contract_num=<?echo $contract_num?>&sortby=1" class="content">Address</a></div>
</td>
<td width="111" align="center" valign="top" nowrap><div align="center"><a href="../../portfolio/list.php?contract_num=<?echo $contract_num?>&sortby=2" class="content">City</a></div>
</td>
<td width="28" align="center" valign="top" nowrap><div align="center"><a href="../../portfolio/list.php?contract_num=<?echo $contract_num?>&sortby=3" class="content">State</a></div>
</td>
<td width="100" align="center" valign="top" nowrap><div align="center"><a href="../../portfolio/list.php?contract_num=<?echo $contract_num?>&sortby=4" class="content">County</a></div>
</td>
<td width="35" align="center" valign="top" nowrap><div align="center"><a href="../../portfolio/list.php?contract_num=<?echo $contract_num?>&sortby=5" class="content">Units</a></div>
</td>
<td width="58" align="center" valign="top" nowrap><div align="center"><a href="../../portfolio/list.php?contract_num=<?echo $contract_num?>&sortby=6" class="content">Bedrooms</a></div>
</td>
<td width="32" align="center" valign="top" nowrap><div align="center"><a href="../../portfolio/list.php?contract_num=<?echo $contract_num?>&sortby=7" class="content">Baths</a></div>
</td>
<td width="102" valign="top"><div align="center"><a href="../../portfolio/list.php?contract_num=<?echo $contract_num?>&sortby=8" class="content">Assessed
Value</a></div>
</td>
<td width="102" valign="top">
</form>
<form name='filter' action='checked.php' method='post'>
<input type='submit' name='submit' value='Filter' ></td> </tr>That is the HTML part with the form.. below is the coding..
Code: Select all
<?// execute the statement
if (!$result = mysql_query($stmt, $dblink)) {
print("There was and error in the query ".mysql_error());
print("<input type=\"button\" value=\"Back\" onClick=\"self.history.back();\">");
exit();
} else {
while ($row = mysql_fetch_array($result)) {
$row_color = altBgColor();
print ("<tr bgcolor=\"".$row_color."\">\n");
print "\n<td align=\"left\" nowrap>
<a href=\"show_property.php?id=
".$row["ID"]."\">Details</a></td>";
print "\n<td align=\"left\">".$row["address"]."</td>";
print "\n<td align=\"left\">".$row["city"]."</td>";
print "\n<td align=\"left\">".$row["state"]."</td>";
print "\n<td align=\"center\">".$row["county"]."</td>";
print "\n<td align=\"left\">".$row["units"]."</td>";
print "\n<td align=\"left\">".$row["bedrooms"]."</td>";
print "\n<td align=\"left\"nowrap>".$row["baths"]."</td>";
print "\n<td align=\"left\"nowrap>".$row["assessed_value"]."</td>";
print "\n<td align=\"left\"nowrap><input type='checkbox' name='kc' value='ck' /></td>";
print "</tr>";
}
}
?>
</table>Once again, any help would be great, thanks!
d11wtq | Like the man himself says - we have
Code: Select all
tags for PHP code [/color]