Trying to get this loop to return all the records

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:

$getnews = mysql_query(“select * from news ORDER BY id DESC”);
/* echo("$title on $date





"); */


<?php print $title;?> <?php print $sector;?> <?php print $location;?> <?php print $salary?>
Description <?php print $details;?>

THanks for your time.


[b]Admin Edit: Changed (bold) tags to [php] Tags for readability. Please see for posting guidelines

Can you try putting this between the $getnews = line and the while( line:


That’s one nifty PHP function to examine what exactly is in your arrays (and in arrays inside arrays). Because I have a feeling your query only returns one row (which it should only do if there’s only one row in your table).

I have inserted the text but it still only returns the one row.

Any further ideas?



If print_r() only returns one line, then the MySQL resource only has one line :) Which means there’s only one line returned by the SQL query, which means there’s only one row in your ‘news’ table.

Sponsor our Newsletter | Privacy Policy | Terms of Service