PDA

View Full Version : Blank?


dizzyd
5-31-08, 01:26 PM
This is a super simple script and looks correct, yet i get a blank screen. Does anything look incorrect?


<?php

include 'dbconfig.php';
include 'opendb.php';

$string = $_POST['search'];

$sql = "SELECT * FROM dealers WHERE zip LIKE '$string'";
$query = mysql_query($sql) or die(mysql_error());
$row_sql = mysql_fetch_assoc($query);
$total = mysql_num_rows($query);


if($total>0) {
while ($row_sql = mysql_fetch_assoc($query)) {//echo out the results
echo "Search Successfull. Blah Blah Blah";
}
} else
{
echo "No results to display";
}


?>

I have a simple database with dealer info such as business name, phone, web, city, state, zip. And i just wanted to be able to do a zip search to pull up the listing. No dice :(. Any ideas?

dizzyd
6-1-08, 01:18 AM
*UPDATE*
ok, i removed

while ($row_sql = mysql_fetch_assoc($query))


and the script worked (sorta). however i obviously cant keep looping as i will only get 1 result this way. I don't know if it was because the db only had 1 enrty? I dunno. But for some reason the second i put "WHILE" back in there i get blank screen. So for the time being i can only display 1 result... Any Ideas?

HalfaBee
6-1-08, 02:25 AM
remmove the line with $row_sql=...

dizzyd
6-1-08, 02:52 AM
you are awesome as usual! Thanks a ton! Only been workin' on this friggin' issue for 24 hours! Thanks again!