Jump to content

Recommended Posts

Hey guys,

What i need to do is select the two last added articles from the table "news" and display them on my front page.

I need to, say, when i have selected the 2nd last added item display only one particular column. I.e the newstext column.

[a href=\"http://img339.imageshack.us/img339/3136/example0fh.jpg\" target=\"_blank\"]http://img339.imageshack.us/img339/3136/example0fh.jpg[/a]

And when a new item is added to DB, the news will drop down one, and the old "2nd to last added" will drop off.

I am unsure on how to select both an individual record field, like "Newstext" and also how to select say the 2nd or 3rd last added entry.

Sorry for bad explanation but thats the best i can do :)

hope you guys can help me out here. Ive been stuck on this for a week or so.
Link to comment
https://forums.phpfreaks.com/topic/11330-record-retrieval-from-database/
Share on other sites

[!--quoteo(post=380670:date=Jun 6 2006, 06:10 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Jun 6 2006, 06:10 PM) [snapback]380670[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[code]
if($result && mysql_num_rows($result) > 0) // error checking
{
     while($row = mysql_fetch_array($result))
     {
          echo $row['column1'];
          echo $row['column2'];
     }
}
[/code]
[/quote]

thats almost what im looking for, however this outputs all the fields in those columns. I just want to output say the 2nd last added record, or the 3rd added record on thier own.

thanks for your help.
I put that in but then i get this error:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: mysql_result(): Unable to jump to row 2 on MySQL result index 5 in /home/.... file.php on line 110[/quote]

I definitely have the records in my DB to display so im a bit stuck.
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.