Jump to content

Recommended Posts

hi
im 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 table
thanks
Link to comment
https://forums.phpfreaks.com/topic/9310-simple-display-in-table-question/
Share on other sites

sorry i didnt explain myself very well there
all 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]

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]
no that still doesnt work

what 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
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.