Jump to content

please help with "button" problem


xcali

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.