lc21 Posted July 15, 2007 Share Posted July 15, 2007 I am developing a log for problems recorded with a system and I have these problems being output to a table within a form and each record has a radio button for the user to select. they are being output as in the code below: <?php while($display=mysql_fetch_array($query)) { echo "<tr><td>".$display['problemId']."</td><td>".$display['name']."</td></tr>"; } ?> How do I get the unique identifer (problemId) to be chosen when the user selects the appropreate radio button? as problems can be added and removed all the time. Thanks. Link to comment https://forums.phpfreaks.com/topic/60019-solved-logic-help/ Share on other sites More sharing options...
nloding Posted July 15, 2007 Share Posted July 15, 2007 If I understand what you're asking ... you're going to need to do a query based on the value of the radio button. So if the radio button is named "problem" or something ... SELECT * FROM table WHERE problemid=$_POST[problem] Or something like that. Link to comment https://forums.phpfreaks.com/topic/60019-solved-logic-help/#findComment-298507 Share on other sites More sharing options...
dbillings Posted July 15, 2007 Share Posted July 15, 2007 <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> <?php while($display=mysql_fetch_array($query)) { echo "<tr><td>".$display['problemId']."</td><td>".$display['name']."</td> <td><input type=\"radio\" name=\"problemId\" value=\"$display\"></td></tr>"; } ?> <tr> <td> <input type="submit" value="Submit"> < /form> </td> </tr> Link to comment https://forums.phpfreaks.com/topic/60019-solved-logic-help/#findComment-298568 Share on other sites More sharing options...
lc21 Posted July 16, 2007 Author Share Posted July 16, 2007 <td><input type=\"radio\" name=\"problemId\" value=\"$display\"></td></tr>"; In the value aspect of this line of code what would be displayed is it the first element of the array and if so how do you display the other elements? Thank you Link to comment https://forums.phpfreaks.com/topic/60019-solved-logic-help/#findComment-299492 Share on other sites More sharing options...
trq Posted July 16, 2007 Share Posted July 16, 2007 $display is an associative array... so somthing like... <td><input type=\"radio\" name=\"problemId\" value=\"{$display['fieldname']}\"></td></tr>"; would be the correct way to display it. Link to comment https://forums.phpfreaks.com/topic/60019-solved-logic-help/#findComment-299495 Share on other sites More sharing options...
lc21 Posted July 16, 2007 Author Share Posted July 16, 2007 Thanks I am having a hard time learning all the syntax I always end up getting my " " or ' ' mixed up. Link to comment https://forums.phpfreaks.com/topic/60019-solved-logic-help/#findComment-299501 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.