Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- html formatting with mysql_fetch_array()
March 28, 2005, 8:54 am
rate this thread
I'm struggling how to format out in a html table after doing a query.
$result = mysql_query("SELECT state_name, county_name, party_name,
votes FROM regions, county, party, results
order by state_name, county_name, votes DESC")
Note: i am odering by 'state', then 'county', then ordering the parties
by no. of votes descending.
Fetching the rows:
while ($row = mysql_fetch_array($result))
echo("<p>" . $row["state_name"] . " " . $row["county_name"]
.." " . $row["party_name"] . " " . $row["votes"] ."</p>");
example output (e.g. state county party votes):
Kentucky Knox PartyA 5987
Kentucky Knox PartyB 1456
Kentucky Livingstone PartyB 10876
Kentucky Livingstone PartyA 2376
Texas Austin PartyB 11343
Texas Austin PartyA 3456
Texas Hamilton PartyA 8076
Texas Hamilton PartyB 1987
I would really like the layout to look something like (eventually in an
i'm going loop da loop with this one. How do I do it?