xcali Posted April 27, 2008 Share Posted April 27, 2008 Hey guys I'm stuck with this problem and i cant seem to solve it Heres the thing: Whenever there are results printed, each available class is printed with the name, date, room and time. What i wanted to do is add a button for each of the rows where if they would click it - the class would be added to their schedule each class has a hidden ID, and i wanted the value of ID be "hidden" in that button and carried to another page when they click it: $data = mysql_query("SELECT class_day, class_time, class_name, room_nr, class_id FROM classinfo WHERE instructor_id='0' and class_name LIKE '%$courses%'"); $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, but there aren't any classes avilable at this time<br><br>"; } else { echo "<table align='center' cellspacing='25' cellpadding='1' >"; echo "<tr> <td align='left'><b>Course Name</b></td> <td align='left'><b>Course Date</b></td> <td align='left'><b>Course Time</b></td> <td align='left'><b>Room Nr</b></td> <td align='left'><b>xxxx</b></td>" ; while($result = mysql_fetch_array( $data )) { echo "<tr><td align='left'>" . $result['class_name'] . "</td> <td align='left'>" . $result['class_day'] . "</td> <td align='left'>" . $result['class_time'] . "</td> <td align='left'>" . $result['room_nr'] . "</td> <td align='left'><FORM METHOD='POST' ACTION='addcourse2.php'> <INPUT name=".$result['class_id']." TYPE='submit' VALUE='Add Course'></FORM> </td>"; } echo "</table>"; } } ?> what i have problem with is: <FORM METHOD='POST' ACTION='addcourse2.php'> <INPUT name=".$result['class_id']." TYPE='submit' VALUE='Add Course'></FORM> i want the ".$result['class_id']." to be carried to another page - addcourse2.php, and then addcourse2 to perform a query where it would do something like "insert into blablabla where instructorid=.$result['class_id']" Can i please get some advise on what im doing wrong here Thank you Link to comment https://forums.phpfreaks.com/topic/103154-please-help-with-button-problem/ Share on other sites More sharing options...
woobarb Posted April 27, 2008 Share Posted April 27, 2008 theres 3 ways you could do this: a) use an array of buttons b) have separate form for each element c) append the id to each button name and check for which instance was used Link to comment https://forums.phpfreaks.com/topic/103154-please-help-with-button-problem/#findComment-528437 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.