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.

Coding Forum


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



Reply
Old 02-24-2004, 06:28 AM PHP database problem
Wenslock's Avatar
Webmaster Talker

Posts: 746
Location: Lincoln, UK
Trades: 0
Hi.

I've got another PHP problem, this time It's sorta to do with a MySQL database.

I've got a link the database working, no problem. The only problem is, I only want it to display the last three rows of information. I know there is a way to do this, but as I'm reasonably new to PHP, it's sorta pushing my limits really.

If someone could help, I'd be really happy!
Wenslock is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-24-2004, 07:16 AM
Lippy's Avatar
LipWeb.Net

Posts: 270
Trades: 0
Okay, sounds like you want a mysql query run through php that only grabs "row1", "row2" and "row3".

PHP Code:
<?
$result 
mysql_query("SELECT row1, row2, row3 FROM table_name WHERE id='1'");

if (!
$result)
{
     echo(
"<p>Unable to locate query results at this time.</p>");
     exit();
}
?>
__________________

Please login or register to view this content. Registration is FREE
"Less Lip More Service"
Providing Quality Hosting at Fair Prices
AIM: LipWebNet MSN: daniel[at]lipweb.net Yahoo: LipWebNet ICQ: 265771633
Lippy is offline
Reply With Quote
View Public Profile Visit Lippy's homepage!
 
Old 02-24-2004, 07:33 AM
Wenslock's Avatar
Webmaster Talker

Posts: 746
Location: Lincoln, UK
Trades: 0
I think you are close lippy! It needs to display the last 3 rows available (it's for a news page). So everytime the user updates it, it will remove the oldest news and will replace it with the new.

ie

2004 - 12 - 02

blabla

2004 - 11 - 02

blablabla

2004 - 10 - 02

zzzzzzzzzzz

------------------------------------------------
now if I updated it, the PHP would kick out something like this
------------------------------------------------

2005 - 01 - 02

new message

2004 - 12 - 02

blabla

2004 - 11 - 02

blablabla

-------------------------------------------

does this make anymore sense?
__________________
------------------------------------------------------------

Please login or register to view this content. Registration is FREE
- Black Prism professional web design services
------------------------------------------------------------
Wenslock is offline
Reply With Quote
View Public Profile
 
Old 02-24-2004, 08:21 AM
Wenslock's Avatar
Webmaster Talker

Posts: 746
Location: Lincoln, UK
Trades: 0
does anyone understand what I mean exactly? I need to display the three latest records from the database I've created.
__________________
------------------------------------------------------------

Please login or register to view this content. Registration is FREE
- Black Prism professional web design services
------------------------------------------------------------
Wenslock is offline
Reply With Quote
View Public Profile
 
Old 02-24-2004, 02:08 PM
Lippy's Avatar
LipWeb.Net

Posts: 270
Trades: 0
Okay you mean the last three entries into the database?
__________________

Please login or register to view this content. Registration is FREE
"Less Lip More Service"
Providing Quality Hosting at Fair Prices
AIM: LipWebNet MSN: daniel[at]lipweb.net Yahoo: LipWebNet ICQ: 265771633
Lippy is offline
Reply With Quote
View Public Profile Visit Lippy's homepage!
 
Old 02-26-2004, 06:39 PM
Novice Talker

Posts: 5
Trades: 0
Just add
PHP Code:
ORDER BY id DESC LIMIT 0,
to your query. "id" being the primary key of your table.
__________________

Please login or register to view this content. Registration is FREE
- Write articles for us and get links back your site!
RockNRollPig is offline
Reply With Quote
View Public Profile Visit RockNRollPig's homepage!
 
Old 02-27-2004, 11:20 AM
Wenslock's Avatar
Webmaster Talker

Posts: 746
Location: Lincoln, UK
Trades: 0
Cheers RockNRollPig. I was able to sort it out though Thanks for trying to help anyway
__________________
------------------------------------------------------------

Please login or register to view this content. Registration is FREE
- Black Prism professional web design services
------------------------------------------------------------
Wenslock is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP database problem
 

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