View Single Post
  #1  
Old 08-19-2006, 10: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
  Webmaster Forums - View Single Post - display latest database entry
View Single Post
  #1  
Old 08-19-2006, 10: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