Jump to content

Help designing a table


af1

Recommended Posts

Hi i am currently designing a mysql database for my website, i am displaying the information in a table, previously i entered all the data by hand in a table on my website including sub headings etc.

how do i format the table now im using php?

i.e. font colour table width cell width etc?

 

here is an example

http://www.tunethat.com/audi.html

subheadings white text etc

here it is with php

http://www.tunethat.com/1audi.php

 

how do i get it looking pretty again?

Link to comment
https://forums.phpfreaks.com/topic/171344-help-designing-a-table/
Share on other sites

This should probably be in the PHP help, but here:

 

First do this:

<?php

include "db.php"; 
$result=mysql_query("SELECT * FROM [b]TABLE NAME [/b] WHERE [b]CONDITION[/b]") or die(mysql_error());

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

 

That will get everything from your table. Next, you want it to echo all of your rows.

<?php
echo "<table><tr><td>Model</td><td>Engine</td><td>Standard BHP</td><td>BHP Increase</td>
<td>Torque Increase</td></tr>";

include "db.php"; 
$result=mysql_query("SELECT * FROM [b]TABLE NAME [/b] WHERE [b]CONDITION[/b]") or die(mysql_error());

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

 

Now I added the <table> BEFORE THE SELECT STATEMENT. You don't want to keep echoing <table> over and over.  :D

 

NEXT, we want to echo all of our database info into rows to make a nice table.

 

 

<?php
echo "<table><tr><td>Model</td><td>Engine</td><td>Standard BHP</td><td>BHP Increase</td>
<td>Torque Increase</td></tr>";

include "db.php"; 
$result=mysql_query("SELECT * FROM [b]TABLE NAME [/b] WHERE [b]CONDITION[/b]") or die(mysql_error());

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


//NEXT WE ADD THIS
echo "<tr><td>".$row['ROW NAME']."</td>...."; //keep echoing <td> until you are done. At the end add </tr>. 
} 
echo "</table>"; 
?>

 

Hope this is what you wanted. >_>

Drop php for a week or two, and learn some HTML and CSS. PHP outputs html (which CSS acts upon). If you don't know what the final product (html) is supposed to look like, then how are you going to make it (PHP)? It's like trying to paint a picture of someone famous, without ever having seen the person you are trying to paint. You are trying to do everything out of order. First, learn what the final product is. Then, learn how to make it. Not the other way around.

Thanks for the advice, i sat and read through lines of code, working out what everything did and what statements mean what, and have managed to do it! im pretty chuffed that i managed to do it myself, its probably a sloppy lot of code but its the first time i have hard coded since ...

 

<html>

<title>my cool 12years old simpsons website</title>

<body> <img scr="C:/My documents/simpsons.bmp"> Hi this is my weel cool simpsons website that i makde its pretty cool but i dont know why my poics dnt work lol

</body>

</html>

 

hehe those were the days!

 

Drop php for a week or two, and learn some HTML and CSS. PHP outputs html (which CSS acts upon). If you don't know what the final product (html) is supposed to look like, then how are you going to make it (PHP)? It's like trying to paint a picture of someone famous, without ever having seen the person you are trying to paint. You are trying to do everything out of order. First, learn what the final product is. Then, learn how to make it. Not the other way around.

 

Directed at me or af1?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.