PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
$content=mysql_query("select * from mos_content ORDER BY `id` DESC LIMIT 0,5") or die(mysql_error());
while ($donnee = mysql_fetch_array($content))
{ $title= $donnee['title'];
}
?>
<?php
echo $title;
echo "</br>";
?>
ok i have that, I am trying to display the last 5 titles added to the database. Only one title is appearing on the page. I think im missing something to make it show 5.
Wait, I didnt even notice your loop. Each time through, it sets $title, effectively overwriting the last one. You need to either store the titles in an array, and loop through the array. You could also put your output code in the while loop, like this:
$content=mysql_query("select * from mos_content ORDER BY `id` DESC LIMIT 0,5") or die(mysql_error());
while ($donnee = mysql_fetch_array($content))
{
$title= $donnee['title'];
echo $title;
echo "<br>";
}