Fearpig Posted September 28, 2006 Share Posted September 28, 2006 Hello,Bit of a vague question for someone! ??? I'm trying to loop some PHP so that it displays a set of results, increases one of the parameters and displays the next set. It needs to stop looping on the 7th pass!Basically I need it to list todays jobs, then list the next days jobs ... up to a week. I can't just order by date as I need them grouped and not just in a list. Here's a rough idea of the code but there are lots of errors... could someone point me in the right direction or send me a link to a tutorial. :)<?php$day=0//sets the day value back to 0 - days run 0,1,2,3,4,5,6,$startdate=date("Y/m/d")//sets the initial date to the current datewhile ($day < 7){//not sure if I can write conditions like this! $selectdate = date( "Ymd", mktime(0, 0, 0, date("m"), date("d")+$day, date("y")) ); //increase $startdate by the current value of $day $conn=odbc_connect('OU_PROD','ou_dba','dba'); if (!$conn) {exit("Connection Failed: " . $conn);} $sql="SELECT request_id, date FROM assignment WHERE date = '$selectdate'"; $rs=odbc_exec($conn,$sql); if (!$rs) {exit("Error in SQL");} echo "$selectdate<br>"; while (odbc_fetch_row($rs)) { $Request=odbc_result($rs,"request_id"); echo "$Request<br>"; }$day = ($day +1)//fairly sure that this won't work as it refers to itself!}?>Any help would be appreciated as this will remove a load of nearly identical pages.CheersTom Link to comment https://forums.phpfreaks.com/topic/22368-looping/ Share on other sites More sharing options...
HuggieBear Posted September 28, 2006 Share Posted September 28, 2006 Hi,Change:[code=php:0]$day = ($day +1);[/code]To:[code=php:0]$day++;[/code]RegardsHuggie Link to comment https://forums.phpfreaks.com/topic/22368-looping/#findComment-100197 Share on other sites More sharing options...
Fearpig Posted September 28, 2006 Author Share Posted September 28, 2006 Thanks Huggiebear! I'll have a play with that and see what I can do.(It always seems to be you or Wildteen that helps me!) Link to comment https://forums.phpfreaks.com/topic/22368-looping/#findComment-100241 Share on other sites More sharing options...
HuggieBear Posted September 28, 2006 Share Posted September 28, 2006 That's because we're sad and sit on here all day :DHuggie Link to comment https://forums.phpfreaks.com/topic/22368-looping/#findComment-100243 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.