vickytam Posted April 12, 2006 Share Posted April 12, 2006 Dear all,I wrote some code as below:<?php…… (Connected to database & get 10 records from database (using array function)$name = $row['name'];$id = $row['id']; ?><form name="input" action="test2.php" method="get"><table border="1"><tr><td><?php echo $name; ?></td><td><?php echo $id; ?></td><td><input type="checkbox" name="check" value ="1">Record checked<br><td><input type="checkbox" name="del" value ="1">Delete?<br></tr></table><input type="submit" value="Submit"></form>There are 10 records were loaded via array function.Would you help to tell me how can I post the value to "test2.php" when I clicked the checkbox.Thank you.Vicky Quote Link to comment Share on other sites More sharing options...
Barand Posted April 12, 2006 Share Posted April 12, 2006 You use a single form and list the 10 records within it.Give the checkboxes values = id of each recordPut '[]' at end of checkbox names so they get posted as arrays[code]<form name="input" action="test2.php" method="get"><table border="1"><?phpwhile ($row = mysql_fetch_array($result)) { $name = $row['name']; $id = $row['id'];?> <tr> <td><?php echo $name; ?></td> <td><?php echo $id; ?></td> <td><input type="checkbox" name="check[]" value ="<?php echo $id; ?>">Record checked<br> <td><input type="checkbox" name="del[]" value ="<?php echo $id; ?>">Delete?<br> </tr><?php}?></table><input type="submit" value="Submit"></form>[/code]To process[code]echo "These ids were checked<br>";foreach ($_GET['check'] as $checkedid) echo "$checkedid<br>";echo "<br>These ids were checked for deletion<br>";foreach ($_GET['del'] as $delid) echo "$delid<br>";[/code] Quote Link to comment Share on other sites More sharing options...
vickytam Posted April 12, 2006 Author Share Posted April 12, 2006 Thank you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.