Identify last row in DB
Posted: Wed May 28, 2008 3:57 am
I have a question. See if anyone can help me by giving some ideas.
Say I have three blog posts posted on different dates and times. When I log into my account and clicks blog button it shows the subject lines of recently posted blogs order by date and time (the most recent will appear at the top) on the left hand side of the page. When clicked on any of these subject lines the full blog post will be displayed in the middle of the page. I have manged to do this by far. Where I am stuck now is : I want to be able to show the most recently posted blog by default. So, when a user clicks on blog button they can see blog subject lines on the left hand side and in the middle the latest blog's content. As they click on different subject lines, the middle bit will change accordingly.
Say user Jay has 3 blog posts : So the sql command I can write is:
[sql] SELECT * FROM blogs WHERE username = "Jay" ORDER BY date DESC; [/sql]
This will return all three rows from the database, but how will I display the content of the most recent one? In other word how do I knoww what is the latest blogId of user Jay?
Say I have three blog posts posted on different dates and times. When I log into my account and clicks blog button it shows the subject lines of recently posted blogs order by date and time (the most recent will appear at the top) on the left hand side of the page. When clicked on any of these subject lines the full blog post will be displayed in the middle of the page. I have manged to do this by far. Where I am stuck now is : I want to be able to show the most recently posted blog by default. So, when a user clicks on blog button they can see blog subject lines on the left hand side and in the middle the latest blog's content. As they click on different subject lines, the middle bit will change accordingly.
Say user Jay has 3 blog posts : So the sql command I can write is:
[sql] SELECT * FROM blogs WHERE username = "Jay" ORDER BY date DESC; [/sql]
This will return all three rows from the database, but how will I display the content of the most recent one? In other word how do I knoww what is the latest blogId of user Jay?