Reply
Recent Updates
Old 06-21-2008, 06:46 PM Recent Updates
Gilligan's Avatar
Dead Like Me

Posts: 1,608
Name: Stefan
Location: London, UK
OK I want to display 5 recent updates on several pages. I'm going to use MySQL to create a column for date, and column for update (text).

I want to echo the updates in a div, and in the format:

Code:
<p>01/01/01</p>
<p>Update text goes here. i have updated blah....</p>
How would I take the information from the DB and echo it like the above? And how can I limit the amount of updates to be echoed to five?

Thanks for any response
Gilligan is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 06-21-2008, 08:24 PM Re: Recent Updates
JeremyMiller's Avatar
Full-Time TeraTasker

Posts: 984
Name: Jeremy Miller
Location: Reno, NV
Something like this should get you started.

PHP Code:
<?php
//Assume $database is an instance of MySQLi
$recent_updates '';
if (
$my_query $database->query("SELECT last_updated, page_text FROM my_table ORDER BY last_updated DESC LIMIT 5")) {
  if (
$my_query->num_rows >0) {
    while (
$a_result $my_query->fetch_object()) {
    
$recent_updates .= '
<p>'
.date('m/d/y',strtotime($a_result->last_updated)).'</p>
<p>'
.htmlentities($a_result->page_text).'</p>';
    }
  }
}
if (
strlen($recent_updates) > 0) {
  echo 
'<div class="recent_updates">'.$recent_updates.'</div>';
}
?>
__________________
Jeremy Miller - TeraTask Technologies, LLC
Content Farmer - Automated Posting for Content & Blog Sites
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 06-22-2008, 06:45 AM Re: Recent Updates
Gilligan's Avatar
Dead Like Me

Posts: 1,608
Name: Stefan
Location: London, UK
Thanks, whats MySQLi sorry?
Gilligan is offline
Reply With Quote
View Public Profile
 
Old 06-22-2008, 03:15 PM Re: Recent Updates
JeremyMiller's Avatar
Full-Time TeraTasker

Posts: 984
Name: Jeremy Miller
Location: Reno, NV
It gives you access to MySQL's "improved" features that were added since 4.0. Examples are prepared statements, stored procedures, stored functions, multi_query. You can see more info at http://www.php.net/mysqli
__________________
Jeremy Miller - TeraTask Technologies, LLC
Content Farmer - Automated Posting for Content & Blog Sites
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Reply     « Reply to Recent Updates
 

Thread Tools

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12715 seconds with 12 queries