Forum Moderators: coopster

Message Too Old, No Replies

Display mySQL in a "table" with PHP

         

dak142

2:26 am on Mar 31, 2004 (gmt 0)

10+ Year Member



I would like to display the contents of my data base. I would like it to appear in a table that will contine to extend with each additional record. An example of the kind of a table I would like to try and create can be found at fatwallet.com . I really like how it changes color from on record to the next. Any idea on how to produce a table like that?

too much information

2:30 am on Mar 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



use a simple IF statement

set the background color then each time you create a new Row or Cell or whatever you are planning on changing check your color variable and switch it accordingly:

*this is ASP, you can get the idea
if background_color = "#123456" then
background_color = "#654321"
else
background_color = "#123456"
end if

dak142

2:33 am on Mar 31, 2004 (gmt 0)

10+ Year Member



Will I need to define a table somehow before I start that sequence?

too much information

3:28 am on Mar 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yea, you can start your table with an IF as well:

*again in ASP sorry...
<table...>
<tr>
While (make sure there's data in the table)
...
<td>
cell data
</td>
...
if (check for a reason to end the row) then
</tr><tr>
end if
next
</tr>
</table>

It takes some tinkering when you start to put it together but that should give you a good start.