Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 06-21-2008, 07:46 PM Recent Updates
Gilligan's Avatar
Website Designer

Posts: 1,670
Name: Stefan
Location: London, UK
Trades: 0
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
__________________

Please login or register to view this content. Registration is FREE
Gilligan is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-21-2008, 09:24 PM Re: Recent Updates
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
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

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 06-22-2008, 07:45 AM Re: Recent Updates
Gilligan's Avatar
Website Designer

Posts: 1,670
Name: Stefan
Location: London, UK
Trades: 0
Thanks, whats MySQLi sorry?
__________________

Please login or register to view this content. Registration is FREE
Gilligan is offline
Reply With Quote
View Public Profile
 
Old 06-22-2008, 04:15 PM Re: Recent Updates
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
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

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Reply     « Reply to Recent Updates
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.24674 seconds with 12 queries