clown[NOR] Posted April 18, 2007 Share Posted April 18, 2007 hi... i'm working on a website for my fiance's dad... and he's a jazz musician, so I'm making a database for upcoming shows. so, what I wonder now, is there a way to show only upcoming shows, and just exclude the shows older than todays date? what I've got atm is: <?php function visGigs() { c2db("gigs"); $query = "SELECT * FROM gigs ORDER BY dato DESC"; $result = mysql_query($query); if (!$result) { die("Could not run query from database"); } $dbRows = mysql_num_rows($result); if ($dbRows > 0) { echo '<table border="0" cellspacing="1" cellpadding="0" bgcolor="#000000" width="100%"> <tr> <td width="20%" bgcolor="#A1C2A7"><div align="center"><strong>Tid</strong></div></td> <td width="80%" bgcolor="#A1C2A7"><div align="center"><strong>Sted</strong></div></td> </tr> '; while ($dbField = mysql_fetch_assoc($result)) { $dnt = explode(" ", $dbField['dato']); echo '<tr><td width="20%" bgcolor="#A1C2A7" valign="top">'.formatDate($dnt[0]).'</td> <td width="80%" bgcolor="#A1C2A7" valign="top"><a href="?vis=gigs&id='.$dbField['id'].'">'.$dbField['sted'].'</a></td></tr>'; } echo '</table>'; } else { echo "Fant ingen kommende spillejobber."; } } ?> Thanks In Advance - Clown Link to comment https://forums.phpfreaks.com/topic/47556-solved-help-mysql-dont-show-older-than-today/ Share on other sites More sharing options...
AndyB Posted April 18, 2007 Share Posted April 18, 2007 Simplest would be to only retrieve database records that were for future dates: $query = "SELECT * FROM gigs WHERE date > '$today' ORDER BY date DESC"; Wacko formats for database dates just make everything hard work. Best, obviously, is if the dates in the db-table are yyyy-mm-dd format (type = date). $today is date("Y-m-d"). Link to comment https://forums.phpfreaks.com/topic/47556-solved-help-mysql-dont-show-older-than-today/#findComment-232193 Share on other sites More sharing options...
clown[NOR] Posted April 18, 2007 Author Share Posted April 18, 2007 thanks Link to comment https://forums.phpfreaks.com/topic/47556-solved-help-mysql-dont-show-older-than-today/#findComment-232210 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.