af1 Posted August 21, 2009 Share Posted August 21, 2009 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? Quote Link to comment Share on other sites More sharing options...
Cetanu Posted August 22, 2009 Share Posted August 22, 2009 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. 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. >_> Quote Link to comment Share on other sites More sharing options...
haku Posted August 22, 2009 Share Posted August 22, 2009 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. Quote Link to comment Share on other sites More sharing options...
af1 Posted August 22, 2009 Author Share Posted August 22, 2009 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! Quote Link to comment Share on other sites More sharing options...
Cetanu Posted August 25, 2009 Share Posted August 25, 2009 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? Quote Link to comment Share on other sites More sharing options...
haku Posted August 25, 2009 Share Posted August 25, 2009 Him. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.