Jump to content

pasing dynamic drop down menu value's


hyster

Recommended Posts

i have created a seating system.

based on the number of seats booked that value is passed to a page that dynamicly produces a drop down box for each seat booked so the type of seat price can be assigned.

 

this part works fine.

the problem i have is how do i code the recieving page not knowing how many values are going to be passed?

 

this is the drop down menu page

 

Thanks

 

<form action="payment.php?seatco=<?php echo $s_count; ?>" method="post" name="f1">
<div id="tick_select">
<?php
for($i=1; $i<=$s_count; $i++){
$tick= mysql_query("select * from ticket_list"); 
?>
<select name="tick_com<?php echo $i; ?>" id="tick_com" onChange="" title="Choose A Ticket">
<option value="">Select Ticket type</option>
<?php 
while($result= mysql_fetch_assoc($tick))
{ 
?>
<?php echo '<option value="'.$result[ticket_id].'" name="'.$result[price].'">'.$result[type].'</option>';?>
<?php }}?>
</select>
</div>
<INPUT TYPE="submit" VALUE="Select">
</form> 

Link to comment
https://forums.phpfreaks.com/topic/230737-pasing-dynamic-drop-down-menu-values/
Share on other sites

Just add in a counter to your while statement, like this:

 

$i = 1;
WHILE STATEMENT {
etc
$i++;}

 

Then you can pass the value of $i with a hidden form value, like this:

 

<input type="hidden" name="numSelects" value="<?php echo $i; ?>" />

 

Now, in your program, just pull the value of $_POST['numSelects'] and you have the number of times it iterated.

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.