Jump to content

Limiting a query by number and date


ninedoors

Recommended Posts

I run a hockey league and want to post my schedule for the upcoming season.  The problem is that I have 100 games in the season and I want to limit the query to 30 games on the schedule that is posted on my website.  That part was no problem for me but I also would like to have those 30 games be determined by date.  So I would like the script to acquire the current date and post the next 30 games that are upcoming.  I have a date field in the daatbase that is in the form YYYY-MM-DD.  Any help would be great.  Thanks.

Link to comment
Share on other sites

Ok, I took a break and tried to figure this problem out myself and couldn't.  Here is the code I have if anyone could help please let me know.

 

$today = date("Y-m-d");
$query  = "SELECT hometeam, visitingteam, showdate, time FROM $tbl_name WHERE date >= '$today' ORDER BY gamenumber LIMIT 0, 20";
$result = mysql_query($query);

while($row = mysql_fetch_assoc($result))
{
    
$game = $row['gamenumber']; 
    
echo "$game";
   

}

 

The reason I am trying to echo the gamenumber was to make sure that it was working.  All I get is a blank page when I run this query.  The date column in my database has the format 2007-09-22(Y-m-d).  I'm not sure if this is the problem or it is something else.  What I want to achieve here is to take the date the user looks at the webpage and give him the next 20 games on my schedule.  If you need anything else let me know.  Thanks in advance.

 

Nick

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.