I knew it was a long shot to begin with...
Posted: Thu Mar 10, 2011 4:13 pm
I'm going to go ahead and say I've been doing PHP for only about a week now. But here goes:
Basically the idea is to show multiple results (if more than one exists) in a nicely formatted style. But this code shows one healthy result, then 5 "This record does not exist". Sorry if I sound noobish, I'm only 19.
So is there a better way of displaying multiple results?
Code: Select all
$i = 1;
$resultLimit = 6;
$query1 = mysql_query("SELECT *, COUNT('zipcode') FROM `maildrop` WHERE `zipcode` LIKE '".$_POST['zipcode']."'") or die(mysql_error());
while($i < $resultLimit){
$i++;
if($query1){
$result1 = mysql_fetch_array($query1);
$result2 = mysql_fetch_array($query1);
$result3 = mysql_fetch_array($query1);
$countResults = mysql_num_rows($query1);
}
if($result1){
echo ("<strong>"."There are " .$countResults. " result(s)"."</strong>");
echo ("<p>");
echo ($result1['name'] . "<br>");
echo ($result1['address'] . "<br>");
echo ($result1['zipcode'] . "<br>");
echo ($result1['phonenumber'] . "<br>");
echo ("<p>");
}
if($result2){
echo ("<p>");
echo ($result2['name'] . "<br>");
echo ($result2['address'] . "<br>");
echo ($result2['zipcode'] . "<br>");
echo ($result2['phonenumber'] . "<br>");
echo ("<p>");
}
if($result3){
echo ("<p>");
echo ($result3['name'] . "<br>");
echo ($result3['address'] . "<br>");
echo ($result3['zipcode'] . "<br>");
echo ($result3['phonenumber'] . "<br>");
echo ("<p>");
}
else{
echo ("<b>" . $_POST['zipcode'] . "</b>" . " - This record does not exist");
echo ("<br>");
}
}So is there a better way of displaying multiple results?