I have written the following to display dealers from a specific area, I now have to add advanced functionality, this is where i am very confused...
// select the information
$sql2 = "SELECT id, DEALER, ADDRESS2, ADDRESS3, CITY, COUNTY, ZIP, PHONE, EMAIL, WEB FROM trek WHERE County = '$place'";
$result9 = mysql_db_query ($DBName, $sql2, $Link);
// count total rows
$tot = mysql_num_rows($result9);
// define amount of table divisions before new row is started
$tds = 3;
echo "<br><table width=\"100%\" bgcolor=\"#336699\">";
echo "<tr>";
for ($i = 1; $i <= $tot; $i++) {
$row9 = mysql_fetch_array ($result9);
$id = $row9[0];
if ($row9[8] == "") {
$emailcheck = "";
} else {
$emailcheck = "<a href=\"mailto:$row9[8]\">Email Dealer</a>";
}
if ($row9[9] == "") {
$urlcheck = "";
} else {
$urlcheck = "<a href=\"$row9[9]\" target=_blank>Visit Web Site</a>";
}
$img = "<td nowrap valign=\"top\" align=left class=\"dealerbox\" width=\"175\"><div class=\"address1\"><strong>$row9[1]</strong><br>$row9[2]<br>$row9[3]<br><strong>$row9[4]</strong><br>$row9[5]<br>$row9[6]<br>Tel: $row9[7]<br>$emailcheck<br>$urlcheck</div></td><td> </td>\n";
echo "$img";
if ($i % $tds == '0' && $i < $tot) {
echo "</tr><tr><td> </td></tr>\n<tr>\n";
}
}
echo "</tr></table>";
if ($tot == "1") {
echo "<br>$tot Dealer Found";
} else {
echo "<br>$tot Dealers Found";
}
Basically I now need it to search and display dealers by their surrounding counties as well as the county they belong in, the table structure follows this (there are a total of 8 neighbour fields in the counties table and there are more fields in the trek table but I didnt include them because u can see the structure);
table: trek
+----+----------+----------+------+--------+--------+-----+
| id | Company | Address | City | County | Region | Zip |
+---------------------------------------------------------+
| | | | | | | |
+---------------------------------------------------------+
table: counties
+--------+------------+------------+------------+------------+
| County | Neighbour1 | Neighbour2 | Neighbour3 | Neighbour4 |
+--------+------------+------------+------------+------------+
| | | | | |
+------------------------------------------------------------+
I need to query the counties table to retrieve its neighbours and then execute the above query for each neighbour and print them out in the td's three in a row as above;
The only suggestions I have had are table joins which I dont understand 🙁
Can someone help please!
Thanks In Advance
Nick