Jump to content

Missing 1 row every time... SQL Query


wispas

Recommended Posts

I have written a SQL query that for some reason will miss out 1 row...

for example i have 8 results with a city_code of AUH

 

this will display properly when putting the SQL query in PHPMyAdmin, but when done in PHP it will only show 7....

 

Can anyone figure out why it will do this...?

 

SQL:

<?php
// Connect database
include("includes/connectdb.php");
?>

<?php
// get value of id that sent from address bar
$id=$_GET['id'];
// Get records in all columns from table where column id equal in $id and put it in $result.
$result=mysql_query("

SELECT *
FROM city
INNER JOIN hotel
ON hotel.hotel_city_code = city.city_code
WHERE city_id='$id'

");
// Split records in $result by table rows and put them in $row.
$row=mysql_fetch_assoc($result);
// Close database connection.
mysql_close();
?>

 

Displaying all of the hotels:

<?php
while($row=mysql_fetch_array($result)){
?>
<table width="325" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="125" align="left" valign="top"><?php echo '<img src="'.$row['hotel_img'].'" />'; ?></td>
          <td width="200" align="left" valign="top"><div id="hotel_name"><?php echo $row['hotel_name']; ?><br />
      <?php for($i = 0; $i < $row['hotel_star']; $i++)
    echo '<img src="images/star.gif" alt=""/>';   ?></div>
          <div id="hotel_address"><?php echo $row['hotel_address']; ?></div>
          <div id="hotel_desc"><?php echo  nl2br( substr($row['hotel_desc'], 0, 65 )) . "..." ; ?></div></td>
        </tr>
</table>
<br/>
<?php
}
?>

Link to comment
Share on other sites

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.