Jump to content

Recommended Posts

Hello, I'm working on a recent news section.

To post a news article on my website,  on the Admin Control Panel will have a section which has.. an 2 fields.

Article Name - textbox

Article - textarea

 

Then the submit button, what I am guessing.. you'll post the article, and it'll go into a database table with 3 collums.

ID - Article Name - Article - Time Submitted

 

With this table, on every page on my website, will have the recent news section. In that section .. the limit of news will be 3. So.. in a query - LIMIT 3.

Time and date that will be posted in the "Time Submitted", which I understand it will be inserted as "time()" into the DB.

It should be displayed like this.. in the Recent News section on each page;

 

[b]my article[/b]
[b]04/12/09 - 4:47PM[/b]
News here 
News here
News here

[b]my article[/b]
[b]05/12/09 - 1:00PM[/b]
news here
news here
news here

 

Etc etc.

On the "All Updates" page, will display ALL the updates, will will be paginated, which I can do, which will be formatted like the above too, with the most recent first, to the latest last.

 

Any idea on how the Queries would look like. I have a rough idea, but I'm not sure how I'd set it for the Recent News section to be the most recent first. Which would be the same for both queries, just one with LIMIT 3.

$query = mysql_query("SELECT * FROM News ORDER BY (Something to order with most recent first) LIMIT 3") or trigger_error etc etc
$row = mysql_fetch_array($query);

$time //Ill turn the timestamp in the database to a date setting

echo '<strong>'. $row['articlename'] .'<br />'. $time .'</strong><br />'. $row['article'] .''

 

It'd be similar to the whole updates page, just without LIMIT 3.

 

Is this right?

Can you give me in depth information on how to do what I'd like to do.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.