473,395 Members | 1,675 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

html formatting with mysql_fetch_array()

I'm struggling how to format out in a html table after doing a query.

Query is:
$result = mysql_query("SELECT state_name, county_name, party_name,
votes FROM regions, county, party, results
where ...
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"] . "&nbsp;" . $row["county_name"]
.."&nbsp;" . $row["party_name"] . "&nbsp;" . $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
html table):
Kentucky
Knox
PartyA 5987
PartyB 1456
Livingstone
PartyB 10876
PartyA 2376
Texas
Austin
PartyB 11343
PartyA 3456
Hamilton
PartyA 8076
PartyB 1987

i'm going loop da loop with this one. How do I do it?
thanks

Jul 17 '05 #1
1 1535
Don't use tables -- it looks perfect for lists ... check out the <LI>
and <UL> tags online.

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dan Weeb | last post by:
Hi All, I have struggled through this far with help from many of you so thanks. I am stuck again. I am really new to this so don't be harsh :-) There are a few problems. You can run the script...
3
by: josh dismukes | last post by:
/// here is the code i'm getting a parse error on the last line of the code which /// is </html> any help will be much appreciated. <?php session_start ();
1
by: bill | last post by:
Hi, This looks like a simple problem, but I just can't seem to wrap my head around it. I'm trying to build a table dynamically, based on a result set from mysql. There will be 9 results for a...
1
by: billbealey | last post by:
I'm struggling how to format out in a nice html table after doing a query. Query is: $result = mysql_query("SELECT state_name, county_name, party_name, votes FROM regions, county, party,...
8
by: Seth | last post by:
How can I completely turn off the auto formatting of Html in Visual Studio 7? I have tried all possible combinations (at least I think I have) of the Tools / Options / Text Editor / HTML XML /...
2
by: mpar612 | last post by:
Hi everyone, The code posted below retrieves all of the rows from a database table. It paginates them by limiting to 20 results per page. It is supposed to print 5 rows of results with 4...
4
by: McGowan | last post by:
Hi, I'm trying to display data from a mysql database in a HTML table but for some reason my code isn't working. At the moment I have got it to read and display the headers and the first row of the...
9
Tormod
by: Tormod | last post by:
I'm having problems formatting a date retrieved from mysql database. When I retrieve the date it's in the format YYYY-MM-DD. I need to split the Day, Month and Year portions of the date up so that I...
5
by: thatcollegeguy | last post by:
Below are my 3php and 2js files. I create a table using ajax/php and then want to change the values in the tables add(+ number for teamid) id's for each specific td in the table. I don't know...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.