» Quick Links
You can make money on these forums
We Share profits with you
Google
Google Adsense
Google Adwords
YPN
Yahoo
MSN Search
Web Directories
Web Hosting
Web Hosting Offers
Hosting News
Suggestions
Link Building
Domain Names
PHP Forums
MySQL Forums
» More Links
OSP News
Reseller Hosting
Shared Hosting
Dedicated Servers
Google Adsense
Search Engine Marketing
Link Development
Affiliate Marketing


» Advertising
Multiple DC PR Check

Free SEO Tools


Go Back   Webmaster Forums > Website Developement / Programming > PHP Programming and Tips

PHP Programming and Tips Discuss about PHP programming and Share Tips. Ask questions about Scripting and Errors.

Reply
 
Thread Tools Display Modes
  #1  
Old 08-19-2006, 09:35 AM
jivasko jivasko is offline
Junior Member
 
Join Date: Aug 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
jivasko is on a distinguished road
Default display latest database entry

Can someone please tell me how I can display the latest database entry? Here is the code that I am working with:

require "config.php";
// the latest diary entry
$query = "SELECT * FROM diary_contents LIMIT 1";

if ($r = mysql_query ($query)) {

$str = "";
while ($row = mysql_fetch_array ($r)) {
$str .= '<p>'. $row['selectDay'] . ' ' . $row['selectMonth'] . ' ' . $row['selectYear'] . '<br />' . $row['diary_entry'].
'<br /><a href=diary.php>Click here</a> to see more diary entries.</p>';
}
if($str==="")
{
echo 'No entries to be displayed.';
} else {
echo $str;
}
}
mysql_close(); -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Revenue Sharing Ads ( ?):
  #2  
Old 08-19-2006, 09:37 AM
aassddff aassddff is offline
OSP Starters
 
Join Date: Jul 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
aassddff is on a distinguished road
Default

You want to include an ORDER BY and order by a specific field in DESCending order, e.g.

Code:
SELECT * FROM diary_contents ORDER BY date_field DESC LIMIT 1; -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
database conversion issue? Akunh MySQL Forums 1 01-17-2007 06:41 AM
database backing up... santiago MySQL Forums 1 10-02-2006 06:27 AM
10,090 Entry Chinese Learning Database klown Sell Internet Services 0 09-07-2006 01:17 PM
DiscountASP.NET Launches SQL Database Transfer Tool outsourcingplans Web Hosting News 0 08-09-2006 03:23 AM
wanna highlight latest entry jackman ASP forums and Tips 2 07-30-2006 11:54 AM


All times are GMT. The time now is 11:41 PM.