yellowzm Posted December 5, 2008 Share Posted December 5, 2008 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 Quote Link to comment Share on other sites More sharing options...
yellowzm Posted December 5, 2008 Author Share Posted December 5, 2008 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>"; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.