I’ve been stumped by this on! I know the solution is probably an easy one, (I hope!) but I have not been able to get it to work right.
I’m using the following code to create a drop down for the site visitor to select a state that they would like to view the info for:
[php]<?php
require(“dealer_map_dbinfo.php”);
// Write out our query.
mysql_connect($local_host,$username,$password);
@mysql_select_db($database) or die( “Unable to select database”);
$state_name_query = “SELECT state_name FROM states_list”;
// Execute it, or return the error message if there’s a problem.
echo “”;
$state_name = mysql_query($state_name_query) or die(mysql_error());
$dropdown = “”;
while($row = mysql_fetch_assoc($state_name)) {
$dropdown .= "\r\n<option value='{$row['state_name']}'>{$row['state_name']}</option>";
}
$dropdown .= “\r\n”;
echo $dropdown;
mysql_close();
?>
This is working, as far as I can tell. It’s when you click the view list and are taken to the “results” page that I am running into the problem.
this is the code of the “results” page:
[php]<?php
require(“dealer_map_dbinfo.php”);
mysql_connect($local_host,$username,$password);
@mysql_select_db($database) or die( “Unable to select database”);
$state_input=$_POST[‘state_input’];
$state_query=mysql_query(“SELECT state_abv FROM states_list WHERE state_name=’$state_input’”);
$state_array=mysql_fetch_array($state_query);
$state=$state_array[0];
$dealer_num_query=mysql_query(“SELECT COUNT(DISTINCT name) FROM markers WHERE state=’$state’”);
$dealer_num_array=mysql_fetch_row($dealer_num_query);
$dealer_num=$dealer_num_array[0];
echo "SICASS racing Dealers in " . $state_input . “
”;
$i=0;
while ($i < $dealer_num) {
$dealer_query=mysql_query(“SELECT DISTINCT name, address, address2, city, state, zipcode, phone, email FROM markers WHERE state=’$state’”);
$dealer=mysql_fetch_row($dealer_query);
$name=$dealer[0];
$address=$dealer[1];
$address2=$dealer[2];
$city=$dealer[3];
$state=$dealer[4];
$zipcode=$dealer[5];
$phone=$dealer[6];
$email=$dealer[7];
echo $name;
echo “
”;
echo $address;
echo “
”;
echo $address2;
echo “
”;
echo $city;
echo ", ";
echo $state;
echo " ";
echo $zipcode;
echo “
”;
echo $phone;
echo “
”;
echo $email;
echo “
”;
$i++;
}
mysql_close();
?>[/php]
I keep getting the same data repeated over and over, not multiple rows of data.
for example, On the first page I select “Michigan”.
I know that there 35 different entries in the data base that should show up, but all that appears is the first entry 35 times? ???
Any help would be greatly appreciated.