/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] while loop only displaying 1 result

Hey everyone…I’m really confused about this one. I have a while loop and it should be displaying thousands of results, but it is only displaying 1. I once made the mistake of putting my echo statements outside of the while loop which caused the same problem, but I learned from that. Here’s the php:

[code=php]
<?php

$category = ereg_replace(“[^A-Za-z0-9]”, “”, $_GET[‘category’]);

$query = “SELECT * FROM members WHERE category=’$category’ ORDER BY accounttype DESC”;

$sql = mysql_query($query);

$count = mysql_num_rows($sql);
if ($count < 1) {
echo “Nothing found for this category.”;
exit();
}

while($row = mysql_fetch_array($sql)){

echo “<div style=’background-image:url(images/account” . $row[“accounttype”] . “.jpg);height:212px;overflow:hidden;’>”;
echo “<h2 class=’listingH2′ style=’margin-left: 10px; text-shadow: none;’><a href=’member_profile.php?id=” . $row[“id”] . “‘>” . $row[“business_name”] . “</a></h2>”;
echo “<p>Rating: <img src=’images/” . $row[“rating”] . “of5.png’></p>”;
echo “<p>Category: ” . $row[“category”] . “</p>”;
echo “<div class=’resultAddress’>”;
echo “<p>” . $row[“address”] . “</p>”;
echo “<p>” . $row[“city”] . “,” . $row[“state”] . “&nbsp;” . $row[“zip”] . “</p>”;
echo “<p>” . $row[“phone”] . “</p>”;
echo “</div>”;
echo “<img style=’position:relative;bottom:20px;’ src=’images/listing-div.jpg’ width=’735′ />”;
echo “<div style=’clear:both;’></div>”;
echo “<div class=’resultsAccountType’>”;
echo “<img src=’images/” . $row[“accounttype”] . “.png’>”;
echo “</div>”;

}

?>
[/code]

What am I messing up on here? Any help would be much appreciated!

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@UtopiaTheoryauthorDec 21.2010 — I figured it out...I forgot to close a div...argh.
×

Success!

Help @UtopiaTheory spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...