puja Posted May 8, 2006 Share Posted May 8, 2006 hiim trying to get some values to be shown in a table and im sure most of you are thinking duh that is really easy but im having a mental block with it.i know how to get multiple lines to show but i only want the one specific line of results to show for the current variables.the code is:[code] $type = $_POST["select_type"]; $sleeps = $_POST["select_sleeps"]; $board = $_POST["select_board"]; $pets_allowed = $_POST["select_pets_allowed"];$query3 = "(SELECT accommID, type, sleeps, board, description, pets_allowed, price FROM accommodation WHERE type='$type' && sleeps = '$sleeps' && board='$board' && pets_allowed ='$pets_allowed')"; $result3 = mysql_query ($query3) or die(mysql_error()); //$num = mysql_num_rows($result3); //$num = 0; //if ($num > 0) //{ echo '<FORM METHOD="POST" ACTION="add_pay.php">'; echo '<table align = "center" border = "1" cellspacing = "0" cellpadding = "5"> <tr> <td align="left"><b>Type</b></td> <td align="left"><b>Sleeps</b></td> <td align="left"><b>Board</b></td> <td align="left"><b>Description</b></td> <td align="left"><b>Pets Allowed</b></td> <td align="left"><b>Price</b></td> </tr> '; echo ' <tr> <td align="left">'. $type. '</td> <td align="left">'. $sleeps. '</td> <td align="left">'. $board. '</td> <td align="left">'. description. '</td> <td align="left">'. $pets_allowed. '</td> <td align="left">'. price. '</td> </tr> '; echo '</table>'; echo ' '; echo '<center> <input type="submit" value="Confirm Booking"></center>'; echo '</FORM>';[/code]description and price should be taken straight from the tablethanks Quote Link to comment Share on other sites More sharing options...
ober Posted May 8, 2006 Share Posted May 8, 2006 You never fetch the data:$row = mysql_fetch_array($result);I also don't know what you mean by your last statement. Quote Link to comment Share on other sites More sharing options...
puja Posted May 8, 2006 Author Share Posted May 8, 2006 sorry i didnt explain myself very well thereall the other fields are php variables that have some data stored on them but description and price are not variables, i just need to to insert whatever is in the table for that row where the other variables are from(not sure if that explaination is any better!)code has now been changed to:[code] $type = $_POST["select_type"]; $sleeps = $_POST["select_sleeps"]; $board = $_POST["select_board"]; $pets_allowed = $_POST["select_pets_allowed"];$query3 = "(SELECT accommID, type, sleeps, board, description, pets_allowed, price FROM accommodation WHERE type='$type' && sleeps = '$sleeps' && board='$board' && pets_allowed ='$pets_allowed')"; $result3 = mysql_query ($query3) or die(mysql_error()); $row = mysql_fetch_array($result3); //$num = 0; //if ($num > 0) //{ echo '<FORM METHOD="POST" ACTION="add_pay.php">'; echo '<table align = "center" border = "1" cellspacing = "0" cellpadding = "5"> <tr> <td align="left"><b>Type</b></td> <td align="left"><b>Sleeps</b></td> <td align="left"><b>Board</b></td> <td align="left"><b>Description</b></td> <td align="left"><b>Pets Allowed</b></td> <td align="left"><b>Price</b></td> </tr> '; echo ' <tr> <td align="left">'. $row['type']. '</td> <td align="left">'. $row['sleeps']. '</td> <td align="left">'. $row['board']. '</td> <td align="left">'. $row['description']. '</td> <td align="left">'. $row['pets_allowed']. '</td> <td align="left">'. $row['price']. '</td> </tr> '; echo '</table>'; echo ' '; echo '<center> <input type="submit" value="Confirm Booking"></center>'; echo '</FORM>';[/code] Quote Link to comment Share on other sites More sharing options...
ober Posted May 8, 2006 Share Posted May 8, 2006 Umm... that's still confusing, but if I understand you correctly, you should change it to this:[code]<td align="left">'. $row['type']. '</td> <td align="left">'. $sleeps . '</td> <td align="left">'. $board . '</td> <td align="left">'. $row['description']. '</td> <td align="left">'. $pets_allowed. '</td> <td align="left">'. $row['price']. '</td>[/code] Quote Link to comment Share on other sites More sharing options...
puja Posted May 8, 2006 Author Share Posted May 8, 2006 no that still doesnt workwhat i was trying to explain was that the $type, $board, $sleeps and $pets_allowed have come from the choices that the user has made.however the description and price are not choices. they should just be the fields in the database for the row that was chosen for those choices Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.