I am using a while loop to display all the records of a db but I cannot figure out why it only returns the first record. I have used the same basic format of this while loop in other applications and it works fine. NOt sure what I have missed or done differently.
Code: Select all
mysql_connect($hostname,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
//query to get info according to co_name in co_info tbl
//and if they are classified in this category in categories tbl
$query = "SELECT $info.*, $categories.co_name, $categories.everyday_wear
FROM $info, $categories
WHERE $info.co_name=$categories.co_name AND $categories.everyday_wear='y'
ORDER BY $info.co_name ASC LIMIT 0,10";//limit 10 per page
$result = mysql_query($query) or die (mysql_error());
//place query in array to be echoed and looped
while ( $row = mysql_fetch_array($result))
{
$co_name = $row[0];
$city = $row[1];
$city = trim($city);
$country = $row[2];
$logo_small = $row[3];
?>
<div id="category_list_co">
<img src="img/embellishment_img.png" class="co_top_img" />
<img src="<?php echo $logo_small ?>" />
<ul>
<li>Location:<br />
<!--echo city and country from co_info tbl -->
<?php echo $city ?>, <?php echo $country ?></li>
<li>Company Type: <?php
$query = "SELECT designers FROM $categories WHERE co_name=$info.co_name";//Determine if Copmany is a designer or retailer and display accordingly
$result = mysql_query($query);
if ($result='y')
{
echo 'Designer';
}
else
{
echo 'Retailer';
}
?></li>
<li><a href="#">Full Page/another php script will get the url for the company page</a></li>
</ul>
</div><!-- end category list co div -->
<?php
}//end while loop for category listing
?>
Thanx!
edit:
I get this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\DSlayout2\category_practice2.php on line 33