JSGTPD Posted December 31, 2006 Share Posted December 31, 2006 Hey allI have a webpage that is formatted to query my database and list the results like thisDateDVD Move ReleaseDVD Move ReleaseDVD Move ReleaseDVD Move ReleaseDateDVD Move ReleaseDVD Move ReleaseDVD Move ReleaseDVD Move ReleaseetcProblem is it only list what is coming out for the current month. I want it to list the next 4 weeks worth of titiles, and then every monday get rid of the current week (which whould be the first one listed and do the NEXT 4 weeks worth of releases.Here is my current PHP file. Any help would be great.THANKS![code]<?include("admin/config.php");if(isset($_REQUEST['month']) && $_REQUEST['month']!='' && isset($_REQUEST['cat']) && $_REQUEST['cat']!=''){$month=$_REQUEST['month'];$cat=$_REQUEST['cat'];$current = date("Y-m-d", mktime(0, 0, 0, date("m") , date("d")+7, date("Y")));$thisweek1 = date("Y-m-d",mktime(0, 0, 0, date("m") , date("d")+1, date("Y")));$current_org=date("Y-m-d", mktime(0, 0, 0, date("m") , date("d"), date("Y")));$thissql="SELECT * FROM dvd WHERE MONTH(rel_date) = '$month' AND status='DVD' AND rel_date > '$current_org' GROUP BY rel_date";}else{ $current = date("Y-m-d", mktime(0, 0, 0, date("m") , date("d"), date("Y"))); list($year, $month, $day) = split('[/.-]', $current); $thissql="SELECT * FROM dvd WHERE MONTH(rel_date) = '$month' AND status='DVD' AND rel_date > '$current' GROUP BY rel_date"; //echo $thissql;}$thisresult=mysql_query($thissql) or die(mysql_error()); ?><STYLE type=text/css>A:link {COLOR: #0000FF; font-size:12px; font-family:Verdana, Arial, Helvetica, sans-serif; TEXT-DECORATION: none}A:visited {COLOR: #000000; font-size:12px; font-family:Verdana, Arial, Helvetica, sans-serif; TEXT-DECORATION: none}A:hover {COLOR: #FF0000; font-size:12px; font-family:Verdana, Arial, Helvetica, sans-serif; TEXT-DECORATION: none}A:active {COLOR: #FF0000; font-size:12px; font-family:Verdana, Arial, Helvetica, sans-serif; TEXT-DECORATION: none}</STYLE><table border="0" cellpadding="0" cellspacing="0" width="100%"><?$thissql1="SELECT * FROM dvd WHERE MONTH(rel_date) = '$month' AND status='DVD' AND rel_date > '$current_org' GROUP BY rel_date";//echo $thissql1;//die();$thisresult1=mysql_query($thissql) or die(mysql_error());if(mysql_num_rows($thisresult1)!=0){ while($nrowdvd=mysql_fetch_array($thisresult1)) {?> <tr> <td width="100%" valign="top"> <table border="0" cellpadding="0" cellspacing="0" width="100%" style="margin-top: 1; margin-bottom: 1"> <tr> <td width="100%" valign="top"> <p style="margin-left: 10; margin-right: 10; margin-top: 5; margin-bottom: 5"><font face="Verdana" size="2"> <b> <? $rel_date=$nrowdvd['rel_date']; list($year,$month,$date)=explode("-",$rel_date); echo date("F j, Y", mktime(0, 0, 0, $month, $date, $year)); ?> </b></font></td> </tr> <? $sql="SELECT * FROM dvd WHERE status='DVD' AND rel_date='$rel_date'"; $result=mysql_query($sql) or die(mysql_error()); while($newrowdvd=mysql_fetch_array($result)) { ?> <tr> <td width="100%" valign="top"> <p style="margin-left: 10; margin-right: 10; margin-top: 5; margin-bottom: 5"><font face="Verdana" size="2"> <a target="_parent" href="index.php?action=listdvd&cat=dvd&dvd_id=<?=$newrowdvd['dvd_id']?>"><?=$newrowdvd['title']?></a></font></td> </tr> <? } ?> </table> </td> </tr> <? } } ?></table>[/code] Link to comment https://forums.phpfreaks.com/topic/32350-simple-help-from-the-pros-please/ Share on other sites More sharing options...
JSGTPD Posted December 31, 2006 Author Share Posted December 31, 2006 Anyone?? Link to comment https://forums.phpfreaks.com/topic/32350-simple-help-from-the-pros-please/#findComment-150430 Share on other sites More sharing options...
Barand Posted December 31, 2006 Share Posted December 31, 2006 I'd do something like this (haven't set up the db table, so untested)[code]<?phpfunction weekCommenceDate ($dt) { $dow = date('w', strtotime($dt)); return strtotime ("$dt -$dow days"); //Sunday date}$thisMonday = date('Y-m-d', strtotime('this monday'));$friday4 = date('Y-m-d', strtotime("$thisMonday +32 days"));$sql = "SELECT title, rel_date FROM dvd WHERE rel_date BETWEEN '$thisMonday' AND '$friday4' AND status='DVD' ORDER BY rel_date";$res = mysql_query($sql) or die(mysql_error()); /*** Store titles in array by week commence date*/while (list($title, $dt) = mysql_fetch_row($res)) { $releases[weekCommenceDate($dt)][] = $title;}/*** output the array*/foreach ($releases as $wc => $titles) { echo "<br>Week commencing " . date('jS M', $wc) . "<br>\n"; foreach ($titles as $movie) { echo "$movie<br>\n"; }}?>[/code] Link to comment https://forums.phpfreaks.com/topic/32350-simple-help-from-the-pros-please/#findComment-150501 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.