Hey, first of all thanks for helping me out with this (probably stupid) question :) I did my research but can't find any solutions on google.
开发者_如何学PythonIs it possible to start viewing the last element in my database?
for example:
DATABASE (comments):
name | comment
jan | Test
bert | Test2
sam | Test3
PHP:
$sql="SELECT * FROM comments";
$result=mysql_query($sql);
while($rows=mysql_fetch_array($result)){
echo $rows['name'];
echo $rows['comment'];
}
THE RESULT:
jan Test
bert Test2
sam Test3
MY PURPOSE:
sam Test3
bert Test2
jan Test
Thanks in advance for your help :)
Change your mysql query to sort the result set how you want. In your case it is probably something like
SELECT * FROM comments ORDER BY id DESC
You should add either an id to your table, or at least a timestamp that contains the time and date of insertion of your data row.
Then :
SELECT * FROM comments ORDER BY timestamp DESC
精彩评论