aebstract Posted March 14, 2007 Share Posted March 14, 2007 Eh, sorry for so many questions today, I am having a bit of a coders block it seems I am pulling information from the database and displaying it, and I want to display all of it. Each will be in its own div.. the code is only displaying the last row in the db. I know I am missing something stupid but can anyone tell me what is wrong? Thanks. <html> <head> <link href="stylesheet.css" rel="stylesheet" type=text/css title=default /> </head> <body> <?php mysql_connect("localhost","hmg","hillpass"); mysql_select_db("hmg"); $result = mysql_query("SELECT * FROM contact WHERE readc='0' ORDER BY id ASC") or DIE(mysql_error()); while($r=mysql_fetch_array($result)) { $id=$r["id"]; $typec=$r["type"]; $readc=$r["read"]; $firstname=$r["firstname"]; $lastname=$r["lastname"]; $email=$r["email"]; $body=$r["body"]; $company=$r["company"]; $website=$r["website"]; $telephone=$r["telephone"]; $address=$r["address"]; $city=$r["city"]; $state=$r["state"]; $zip=$r["zip"]; $ip=$r["ip"]; echo " <div id=\"contactdiv\"> $firstname $lastname $email $body </div> "; } ?> </body> </html> edit: ps - I am sure I could do it with some for statement, but can't it be done with this while statement? Link to comment https://forums.phpfreaks.com/topic/42718-solved-while-to-display-all/ Share on other sites More sharing options...
aebstract Posted March 14, 2007 Author Share Posted March 14, 2007 ACK, it works fine. Sorry for the confusion, was in the CSS causing all to overlap eachother. Link to comment https://forums.phpfreaks.com/topic/42718-solved-while-to-display-all/#findComment-207261 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.