sdm Posted March 2, 2007 Share Posted March 2, 2007 I'm trying to get the database to return all the records and format them into table cells, this only outputs the first one. How do I format this so that it puts all sets into table before stopping the loop please. This is the code I currently have: <? include("dbconnect.php"); $getnews = mysql_query("select * from news ORDER BY id DESC"); while($r=mysql_fetch_array($getnews)){ extract($r); /* echo("<b>$title on $date<BR><BR>$sector<BR><BR>$location<BR><BR>$salary<BR><BR>$details</b><BR><BR>"); */ } ?> <div align="center"> <table width="643" border="1" cellspacing="1" cellpadding="1"> <tr> <td width="153"><?php print $title;?></td> <td width="198"><?php print $sector;?></td> <td width="122"><?php print $location;?></td> <td width="147"><?php print $salary?></td> </tr> <tr> <td>Description</td> <td colspan="3"><?php print $details;?></td> </tr> </table> </div> Thanks for your time. SDM Quote Link to comment Share on other sites More sharing options...
craygo Posted March 2, 2007 Share Posted March 2, 2007 <div align="center"> <table width="643" border="1" cellspacing="1" cellpadding="1"> <?php include("dbconnect.php"); $getnews = mysql_query("select * from news ORDER BY id DESC"); while($r=mysql_fetch_array($getnews)){ extract($r); ?> <tr> <td width="153"><?php print $title;?></td> <td width="198"><?php print $sector;?></td> <td width="122"><?php print $location;?></td> <td width="147"><?php print $salary?></td> </tr> <tr> <td>Description</td> <td colspan="3"><?php print $details;?></td> </tr> <?php } ?> </table> </div> Ray Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 2, 2007 Share Posted March 2, 2007 craygo you no the above code you provided you use extract php function would it be faster to use a mysql statement like list? Quote Link to comment Share on other sites More sharing options...
craygo Posted March 6, 2007 Share Posted March 6, 2007 Well I was just adding to his code, he used extract, so who am I to change it. Ray 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.