Jump to content

Displaying records


Ameslee

Recommended Posts

hope someone can help me, i want to know how to display a certain amount of records coming from a database on my website. can anyone help me???

another question!!! once displaying a certain amount of records on the website, how do i keep it up to date so that once a date passes, because i am displaying events and the dates they are on, that one gets replaced with newer ones from the database. thanks!
Link to comment
Share on other sites

[quote name='Ames' date='May 4 2006, 10:41 AM' post='371116']
hope someone can help me, i want to know how to display a certain amount of records coming from a database on my website. can anyone help me???

ive managed to do the above like this:
$i=1;
while (($row!="")&&($i<=6))

now im not sure how to replace records displayed where the dates have passed, please help!!!!!
Link to comment
Share on other sites

Ok im not sure if im making sense so im going to have another go at explaining my probelem.

I am displaying events with dates on a website. I have limited how many records are to be displayed at once, i now want to know how i can keep these records up to date so that events that have passed do not show and are replaced with newer events from the database????

hope this makes sense, thanks
Link to comment
Share on other sites

The easiest way to do this by your specifications would be to use an 'id' column in your database table, assuming that you have one. Just select the last x records from your table, order by 'id' descending.

[code]<?php
$query = "SELECT * FROM table ORDER BY id DESC LIMIT 10";
?>[/code]

Your query would look something like that.

[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--]
Link to comment
Share on other sites

[!--quoteo(post=371470:date=May 5 2006, 06:29 PM:name=jeremywesselman)--][div class=\'quotetop\']QUOTE(jeremywesselman @ May 5 2006, 06:29 PM) [snapback]371470[/snapback][/div][div class=\'quotemain\'][!--quotec--]
The easiest way to do this by your specifications would be to use an 'id' column in your database table, assuming that you have one. Just select the last x records from your table, order by 'id' descending.

[code]<?php
$query = "SELECT * FROM table ORDER BY id DESC LIMIT 10";
?>[/code]

Your query would look something like that.

[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--]
[/quote]

thanks for you help

i have already got this statement:
$query = "SELECT * FROM events ORDER BY Date"; date being my field and events being the table. So when u say id that would be eventid for me, as that is my primary key field. So that simple query, will keep updating new events that are added to my database? thanks! Amy!
Link to comment
Share on other sites

[!--quoteo(post=371782:date=May 6 2006, 08:03 AM:name=Ames)--][div class=\'quotetop\']QUOTE(Ames @ May 6 2006, 08:03 AM) [snapback]371782[/snapback][/div][div class=\'quotemain\'][!--quotec--]
thanks for you help

i have already got this statement:
$query = "SELECT * FROM events ORDER BY Date"; date being my field and events being the table. So when u say id that would be eventid for me, as that is my primary key field. So that simple query, will keep updating new events that are added to my database? thanks! Amy!
[/quote]


SELECT * FROM events ORDER BY Date DESC LIMIT 0, 10

will give you the most recent 10 assuming you have a date field with the date of when its posted.

LIMIT works like this : LIMIT starting number, count

ie.
LIMIT 0, 10 - starts at 0 gives you 10 - records 0 - 9
LIMIT 4, 5 - Starts at result 4 and gives you 4 - records 4 - 9
Link to comment
Share on other sites

[!--quoteo(post=371811:date=May 6 2006, 11:15 PM:name=Dougal Matthews)--][div class=\'quotetop\']QUOTE(Dougal Matthews @ May 6 2006, 11:15 PM) [snapback]371811[/snapback][/div][div class=\'quotemain\'][!--quotec--]
SELECT * FROM events ORDER BY Date DESC LIMIT 0, 10

will give you the most recent 10 assuming you have a date field with the date of when its posted.

LIMIT works like this : LIMIT starting number, count

ie.
LIMIT 0, 10 - starts at 0 gives you 10 - records 0 - 9
LIMIT 4, 5 - Starts at result 4 and gives you 4 - records 4 - 9
[/quote]

ok i have worked it out a different way, others may be interested or have the same problem. I did it this way:$query = "SELECT * FROM events WHERE Date >=now() ORDER BY Date ASC";
Events is my table, Date is my field.

It works well!

Thanks anyways to all!

Amy
Link to comment
Share on other sites

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.