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 Link to comment https://forums.phpfreaks.com/topic/40875-trying-to-get-this-loop-to-return-all-the-records/ 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 Link to comment https://forums.phpfreaks.com/topic/40875-trying-to-get-this-loop-to-return-all-the-records/#findComment-197951 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? Link to comment https://forums.phpfreaks.com/topic/40875-trying-to-get-this-loop-to-return-all-the-records/#findComment-197995 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 Link to comment https://forums.phpfreaks.com/topic/40875-trying-to-get-this-loop-to-return-all-the-records/#findComment-200774 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.