I am new to PHP and mySQL and am trying to generate a simple website that is a resource directory that lists resources by City.
Here is the query I have so far:
Quote:
<? $query = "SELECT * from resourcedirectory where appr=1 GROUP BY city ORDER BY last";
$result=mysql_query($query);
$num=mysql_numrows($result);?>
|
What code would I use from here to display this data?
This is what I have now, but it is not giving me the results I want and I don't think I am coding it as well as I should:
Quote:
<?
$i=0;
while ($i < $num) {
$LAST=mysql_result($result,$i,"last");
$FIRST=mysql_result($result,$i,"first"); $COMPANY=mysql_result($result,$i,"company"); $CITY=mysql_result($result,$i,"city"); $TELE=mysql_result($result,$i,"tele"); $WEBSITE=mysql_result($result,$i,"website");
?>
<? echo $COMPANY; ?>
<? echo $FIRST; ?> <? echo $LAST; ?>
City: <? echo $CITY; ?>
Telephone: <? echo $TELE; ?>
E-mail:<? echo $EMAIL;?>
Website: <? echo $WEBSITE; ?></p>
<?
$i++;
}
;
?>
|
Any help would be greatly appreciated.
Thanks,
Rich