Jump to content

[SOLVED] PHP Next Upcoming events


yellowzm

Recommended Posts

I am designing a website for my kids wrestling team. The team participates in several different season from several different organizations at a time and as a result we have 4-5 tournaments to choose from on some weekends and some weeks with events on several days. I have been able to get the events page working but it is not quite what i want. It will currently display all events starting with the one with the highest date, which can be several months away. That is fine for the archive page, but I want to put the same basic code on the main page of the site and have it display the events from the next week or 2 to a max of 5 events. So if someone could please assist me with this i'd be grateful. btw I am very new to PHP so please forgive my code

            
<?php
   mysql_connect("mysql","user","pass");
   mysql_select_db("braves");
   $query ="SELECT eventtitle, eventbody, eventtime, eventsub, weighin, directions,";
   $query.=" DATE_FORMAT(eventdate, '%M %d, %Y') AS date";
   $query.=" FROM events ORDER BY eventdate DESC LIMIT 10000";
   $result=mysql_query($query);
   while (list($eventtitle,$eventbody,$eventtime,$eventsub,$weighin,$directions,$eventdate,) = 
    mysql_fetch_row($result)) {
       echo "<dt><b><h1>$eventtitle </h1></b></dt>";
   echo "<dd><b><h2>$eventsub </h2></b></dd>";
   echo "<dd><b><h3>($eventdate)</h3></b></dd>";
   echo "<dd><b><h3>$eventtime</h3></b></dd>";
       echo "<dd><b><h4>$weighin</h4></b></dd>";
   echo "<dd> </dd>";
       echo "<dd>$eventbody</dd>";
   echo "<dd> </dd>";
       echo "<dd>$directions</dd>";
  
   }
?>

 

That's the code from the archive page, it works great for me. So, How can it be modified to do what i described above?

 

Thanks in advance for the help

~Zach

 

Link to comment
Share on other sites

I figured it out, it was a very simply fix but I was doing things in the wrong order i guess. Anyway here is how I got it working

   
<?php

   mysql_connect("mysql","user","pass");
   mysql_select_db("braves");
   $today = date('Y-m-d');
   $query ="SELECT eventtitle, eventbody, eventtime, eventsub, weighin, directions,";
   $query.=" DATE_FORMAT(eventdate, '%M %d, %Y') AS date"; 
   $query.=" FROM events WHERE eventdate >= '$today' ORDER BY eventdate ASC LIMIT 5";   
   $result=mysql_query($query);
   while (list($eventtitle,$eventbody,$eventtime,$eventsub,$weighin,$directions,$eventdate,) = 
    mysql_fetch_row($result)) {
       echo "<dt><b><h1>$eventtitle </h1></b></dt>";
       echo "<dd><b><h2>$eventsub </h2></b></dd>";
       echo "<dd><b><h3>($eventdate)</h3></b></dd>";
       echo "<dd><b><h3>$eventtime</h3></b></dd>";
       echo "<dd><b><h4>$weighin</h4></b></dd>";
       echo "<dd> </dd>";
       echo "<dd>$eventbody</dd>";
       echo "<dd> </dd>";
       echo "<dd>$directions</dd>";
    }

 

 

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.