ahh well sense you put it that way... here is the full code starting with
"dealerlocater.php"
[PHP]
<script type="text/javascript" src="ajax/ajax.js"></script>
<script language="JavaScript" type="text/JavaScript">
var div1 = '<select id="city" name="city" style="font-family:Tahoma;font-size:10pt;width:184px;" onchange="getPart(this)"><option value="">Select Your City</option></select>';
var div6 = '<p></p>';
var div7 = '<p></p>';
var ajax = new sack();
var selState;
var selCity;
function buildtop() {
ajax.requestFile = 'getStateInfo.php?buildtop=1';
ajax.onCompletion = makeTop;
ajax.runAJAX();
}
function makeTop() {
document.getElementById("divmsg6").innerHTML = ajax.response;
}
// ================================================== ===============================
// GET the City drop down list after user has selected state
// ================================================== ===============================
function getCity(sel) {
selState = sel.options[sel.selectedIndex].value;
if(selState.length>0){
ajax.requestFile = 'getStateInfo.php?getcity=1&state='+selState;
ajax.onCompletion = createDropdownMake;
ajax.runAJAX();
}
}
// ================================================== ===============================
// DISPLAY the City drop down list
// ================================================== ===============================
function createDropdownMake() {
document.getElementById("divmsg1").innerHTML = ajax.response;
document.getElementById("divmsg7").innerHTML = div7;
}
function getPart(sel) {
selCity = sel.options[sel.selectedIndex].value;
if(selCity.length>0){
ajax.requestFile = 'getStateInfo.php?getpart=1&state='+selState+'&cit y='+selCity;
ajax.onCompletion = createPart;
ajax.runAJAX();
}
}
function createPart() {
document.getElementById("divmsg6").innerHTML = ajax.response;
document.getElementById("divmsg7").innerHTML = div7;
}
// ================================================== ===============================
// show the div6 when page has loaded for first time
// ================================================== ===============================
function showDiv6 () {
// document.getElementById("divmsg6").innerHTML = div6;
}
</script>
<?php
// ================================================== =======
// Populate the state selection list from the database
// ================================================== =======
echo '<form action="" method="post">';
echo '<select id="state" name="state" style="margin-bottom:4px;font-family: Tahoma; font-size: 10pt; height:28px;width:184px;" onchange="getCity(this)">';
echo '<option value="">Select Your State</option>';
// ================================================== =======
// Connection to the Database
// ================================================== =======
include ('db functions/db_connect.php');
// ================================================== =======
// SELECT state to make drop down list
// ================================================== =======
$res = mysql_query("SELECT state FROM dealerlocater GROUP BY state ORDER BY state")
or die("Invalid query: " . mysql_query());
while ($row = mysql_fetch_assoc($res)) {
$st = $row['state'];
echo "<option value='$st'>$st</option>";
}
echo '</select>';
?>
<DIV ID="divmsg1" STYLE="font-family:Tahoma;font-size:10pt;height:26px;overflow:hidden;">
<select id="city" name="city" style="font-family:Tahoma;font-size:10pt;width:184px;" onchange="getPart(this)"><option value="">
Select Your City</option></select>
</DIV>
<DIV ID="divmsg6">
</DIV>
<DIV ID="divmsg7">
</DIV>
[/PHP]
and now the 2nd page
"getStateInfo.php"
[PHP]
<?php
//************************************************** ***********************************
//1. drop down State - select all (grouped by)
//************************************************** ***********************************
// ================================================== =============================
// Connection to the Database
// ================================================== =============================
include ('db functions/db_connect.php');
// ================================================== ========================================
// Get City after user selected State and create City-dropdown
// ================================================== ========================================
if(isset($_GET['getcity']) AND isset($_GET['state'])){
$st = $_GET['state'];
$res = mysql_query("SELECT city FROM dealerlocater WHERE state='$st' GROUP BY city ORDER BY city")
or die("Invalid query: " . mysql_query());
echo '<select id="city" name="city" style="font-family:Tahoma;font-size:10pt;width:184px;" onchange="getPart(this)">';
echo '<option value="">Select Your City</option>';
while ($row = mysql_fetch_assoc($res)) {
$ci = $row['city'];
echo "<option value='$ci'>$ci</option>";
}
echo '</select>';
}
// ================================================== ================================================== =
// Construct parts overview after user selected state, city.
// ================================================== ================================================== =
if( (isset($_GET['getpart']) AND isset($_GET['state']) AND isset($_GET['city']))
OR (isset($_GET['search']) ) ) {
if(isset($_GET['getpart'])) {
$st = $_GET['state'];
$ci = $_GET['city'];
$res = mysql_query("SELECT * FROM dealerlocater WHERE city='$ci' LIMIT 0, 10")
or die("Invalid query: " . mysql_query());
// Loop through
for ($i=1; $i<=4; $i++) {
// build the output array sorted by category
$Array=array();
while ($row = mysql_fetch_assoc($res)) {
$id = $row['id'];
$co = $row['company'];
$ad = $row['address'];
$ci = $row['city'];
$sa = $row['stateabb'];
$zi = $row['zip'];
$ph = $row['phone'];
$we = $row['web'];
$Array=array ();
}
}
echo "$co <br>";
echo "$ad <br>";
echo "$ci, $sa $zi <br>";
echo "$ph <br>";
echo "$we <br>";
echo "<br>";
}
}
?>
[/PHP]
Now I get everything working.... however my issue is what I was asking to be made... I can not make this code here display more then one out put...
In simple terms it will only show me 1 result I search....
When the database holds more then one for the same search I.E
State = WYOMING
City = Casper
Number to display = 2
Number being displayed by the code above = 1...
And for you to see what I mean see
LINK here... do that same search
So at the moment it will return this
Dan Winer
3086 Herrington Dr
Casper, WY 93445
(805) 474-1312
and it should be returning one more company underneath it....