chrispos Posted March 27, 2009 Share Posted March 27, 2009 I am using a hidden field in a form. The idea is to send a number of hidden fields to pass to a form with each individual room having its own id. The site is a hotel booking site. I have tried <?php echo$id;?> But this does not work in this instance. I have tried a number of different ways but with no luck. The code is as follows: $query = "SELECT * FROM `rooms`"; $result = mysql_query($query) or die (mysql_error()); if (mysql_num_rows($result)>0){ while ($row = mysql_fetch_row($result)) { $rid=$row[0]; $hid=$row[1]; $number=$row[2]; $description=$row[3]; $sleeps=$row[4]; $booking = '<form id="form1" name="form1" method="post" action="/form2.php"> <input name="id" type="hidden" id="id" value="$id" /> <input name="hid" type="hidden" id="hid" value="$hid" />'; $booking1 = '<label> <input type="submit" name="Submit" value="Submit" /> </label> </form>'; echo "$booking"; echo"$number\n\n"; echo"$description\n\n"; echo"$sleeps\n\n"; echo "$booking1<br><br>"; } } All the rooms show but as i want to send a number of different information ie $id $hid etc. I would be happy of any help Thank you. Link to comment https://forums.phpfreaks.com/topic/151437-solved-hidden-field-problem/ Share on other sites More sharing options...
kenrbnsn Posted March 27, 2009 Share Posted March 27, 2009 Variables inside single quotes are not expanded, change <?php $booking = '<form id="form1" name="form1" method="post" action="/form2.php"> <input name="id" type="hidden" id="id" value="$id" /> <input name="hid" type="hidden" id="hid" value="$hid" />'; ?> to <?php $booking = "<form id='form1' name='form1' method='post' action='/form2.php'> <input name='id' type='hidden' id='id' value='$id' /> <input name='hid' type='hidden' id='hid' value='$hid' />"; ?> or <?php $booking = '<form id="form1" name="form1" method="post" action="/form2.php"> <input name="id" type="hidden" id="id" value="' . $id . '" /> <input name="hid" type="hidden" id="hid" value="' . $hid . '" />'; ?> Ken Link to comment https://forums.phpfreaks.com/topic/151437-solved-hidden-field-problem/#findComment-795456 Share on other sites More sharing options...
chrispos Posted March 27, 2009 Author Share Posted March 27, 2009 Many thanks works like a dream some times you just cant see the wood for the tress, Many thanks Link to comment https://forums.phpfreaks.com/topic/151437-solved-hidden-field-problem/#findComment-795466 Share on other sites More sharing options...
kenrbnsn Posted March 27, 2009 Share Posted March 27, 2009 Please mark as "Solved" Link to comment https://forums.phpfreaks.com/topic/151437-solved-hidden-field-problem/#findComment-795485 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.