MySQL Forums
Forum List  »  PHP

use EVAL ( ) to list the most recent php pages
Posted by: Matt Crosby
Date: February 24, 2009 04:50AM

Hello, and thanks for giving me a few minutes of your time.

I am relatively new to PHP yet ive done a bit of work on it
Im currently trying to use MYSQL database to store php files that i want to show the most recent 5 pages
I.E the home page automatically shows the last 5 php pages (updated weekly) and archives (with previous pages link at bottom)

I currently am able to make MYSQL show one record, but i cant seem to find a way for it to post more than one at a time, i have some code here, maybe you guys can help me with

If theres an easier way to accomplish what im doing, please dont hesitate to inform me.. ive been up all night looking for answers





?php
// Connects to your Database
mysql_connect("localhost", "mcfox_content", "password") or die(mysql_error());
mysql_select_db("mcfox_content") or die(mysql_error());

//This retrieves the template and puts into an array. No WHERE clause is used, because we only have one template in our database.
$coding = mysql_query("SELECT * FROM template") or die(mysql_error());
$template = mysql_fetch_array( $coding );

//This retrieves the content and puts into an array. Notice we are calling ID 1, this would change if we wanted to call a page stored on a different row

$text = mysql_query("SELECT * FROM content ORDER BY age DESC ") or die(mysql_error());
$content = mysql_fetch_array( $text );

//Actually puts the code and content on the page

Print $template['Head_Open'];
Print $content['title'];
Print $template['Head_Close'];

//When pulling PHP code we need to use EVAL
Eval ($template['Date']);

Print $content['body'];
Print $template['Page_End'];
?>


Currently, it only displays one php page, in this case home.php when there are 4 other records in the same table i wish to be listed.. No matter what ive tried it will only return one result, and not the most recent 3-5 sorted by date

Can anyone help me out? im trying to get a page that displays the most recent php pages and also can release pages by date, automated release.

It should be relatively easy, im sure there is something small i missed.

Thanks again for your time, hope you can help shed some light for me :)

Agent00Crosby

Options: ReplyQuote


Subject
Written By
Posted
use EVAL ( ) to list the most recent php pages
February 24, 2009 04:50AM


Sorry, you can't reply to this topic. It has been closed.
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.