Creating Multiple options for checked values.
Posted: Fri Nov 22, 2002 7:17 pm
Hello there PHP buddies and Gurus. I have set up a form that gives me results from a table and lists them. I have allso set it up so that it places a check box next to each search result. I have then placed two buttons below the search results "Delete" and "Veiw Details". I am curious as to how to make the buttons interact with each search result that has a checked checkbox next to it. So that when the user checks 1 or 2 or 3 of the results and then clicks on the "delete" button for example, the checked results are deleted from the database. Help on the subject would be greatly appreciated.
sorry its so messy
Code: Select all
<?php
$linkID = mysql_connect("localhost","","");
mysql_select_db("ymca", $linkID);
if ($search == "")
{$search = '%';}
$result = mysql_query ("SELECT * FROM members
WHERE lastname LIKE '%$search%'
");
print "<table width=500 valign=top align=center border=1 cellpadding=0 cellspacing=0 bordercolor=#000000><tr><td width=500 height=0 valign=top><form name=search method=post action=search.php>
<table valign=top width=500 height=157 border=1 cellpadding=0 cellspacing=10 bordercolor=#FFFFFF>
<tr bordercolor=#FFFFFF><td nowrap bgcolor=#EBEBEB><div align=left><font size=2>Search Members<font face=Times New Roman, Times, serif></font></font></div></td><td height=12 rowspan=4 nowrap bordercolor=#000000> <div align=center><img src=images/mysql.jpg width=167 height=87></div></td></tr><tr bordercolor=#FFFFFF><td width=204 height=53 nowrap><font size=2><font face=Times New Roman, Times, serif><input name=search type=text id=search2 size=29><input name=membersearch type=submit id=membersearch2 value=Search></font></td></tr><tr bordercolor=#FFFFFF>
<td height=18 align=left valign=top nowrap bgcolor=#EBEBEB><font size=2 face=Verdana, Arial, Helvetica, sans-serif><a href=advsearch.html>Advanced
Search</a></font></td>
</tr><tr bordercolor=#FFFFFF><td height=17 nowrap bgcolor=#EBEBEB><font size=2><a href=mailto:sdiver1500@aol.com>Contact Administrator</a> </font></td></tr></table></form><form name=form1 method=post action=options.php><table width=500 height=0 border=0 cellpadding=0 cellspacing=10><tr bgcolor=#EBEBEB><td width=13 bgcolor=white><font size=2>&nbsp;</font></td><td width=0 nowrap><font size=2>Last Name</font></td><td width=0 nowrap><font size=2>Card Number</font></td><td width=0 nowrap><font size=2>Home Phone Number</font></td></tr>";
if ($row = mysql_fetch_array($result)) {
do { print "<tr>";
print "<td><font size=2>";
print "<input type=checkbox name=check id=check value=1>";
print "</font></td>";
print "<td nowrap><font size=2>";
print $rowї"lastname"];
print "</font></td>";
print "<td nowrap><font size=2>";
print $rowї"cardnum"];
print "</font></td>";
print "<td nowrap><font size=2>";
print $rowї"homenum"];
print "</font></td>";
} while($row = mysql_fetch_array($result));
} else {print "Sorry, no records were found!";}
print "<tr>
<td colspan=4><div align=right>
<input name=add type=submit id=add value=Add>
<input name=delete type=submit id=delete value=Delete>
<input name=veiw type=submit id=veiw value=Veiw Details>
</div></td>
</tr>
</table>
</form> </td></tr>";
print "</table></td>";
?>