Hi,
Am currently having some difficulty in sorting some information retrieved from a MySQL query.
Basically it's for a page (http://www.teatonic.com.au/stockists/search_all.php) which is supposed to retrieve a list of stockists/retailers and then sort them alphabetically by the field containing their Town/Suburb/City (see below).
However, the code below is returning an error that mysql_num_rows is not a valid result - I'm totally lost here, so if anyone can help me it would be appreciated.
<?
$DBName = "stockists";
$table = "stockists";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
@mysql_select_db("$DBName") or die("Unable to select database $DBName"); $sqlquery = "SELECT * FROM ${table} WHERE State = 'VIC' SORT BY City_town, Bus_name ASC";
$result = mysql_query($sqlquery);
if (mysql_num_rows($result))
{
foreach ($result as $row)
{
?>
<dl><dt><?= $row['Bus_name'] ?></dt>
<dd><?= $row['street'] ?></dd>
<dd><strong><?= $row['City_town'] ?></strong>,
<?= $row['State'] ?> <?= $row['Postcode'] ?></dd>
<dd><?= $row['Country'] ?></dd>
<dd>Ph: <?= $row['phone'] ?></dd>
<dd>Fax: <?= $row['fax'] ?></dd>
<dd>Email: <a href="mailto:<?= $row['email'] ?>" title="email
<?= $row['Bus_name'] ?>"><?= $row['email'] ?></a></dd>
<dd>Website: [url]http://[/url]<a href="http://<?= $row['website'] ?>"
target="<?= $row['Bus_name'] ?>"
title="<?= $row['Bus_name'] ?>"><?= $row['website'] ?></a></dd>
<?php
} // end foreach loop
}
else
{
?>
<p>There Were No Results for Your Search</p>
<?php
}
@mysql_free_result($result);
?>