Page 1 of 1

while problem

Posted: Fri Aug 08, 2003 9:52 pm
by skateis2s
Okay, I made a search form...

while($r=mysql_fetch_array($result)) {
$blah=$r["name"];
echo $blah;
echo "<br>";
}



that code works when you hit search, but when I put



while($r=mysql_fetch_array($result)) {
$blah=$r["name"];
echo $blah;
echo "<br>";
} else {
echo "No search results.";
}


it gives me on error and says parse error on the line with

} else {


help please ! thankyou

Posted: Fri Aug 08, 2003 10:07 pm
by Drachlen
Well, it's not an if statement, so what you need to do is make an if checking if the search variable is set, so if your search variable was $search you do somethin like

Code: Select all

<?php
if (isset($search)) {
while($r=mysql_fetch_array($result)) { 
$blah=$r["name"]; 
echo $blah; 
echo "<br>";
}
} else { 
echo "No search results."; 
}
?>