This is a pain. It seems totally logical to me and I had it working before I accidentally saved over the working version (major boo boo).
This is two code snippets, first one is how I want it to work - One Query and the loop through results.
Second does work, but then its going to have to run mysql 60 times, which could get slow as the site gets more use.
$results = mysql_query($query);
$response .= "<table><tr>";
if($nit == 0){
for($i = 0; $i < 60; $i++){
$dateCompare = date("Y-m-d", mktime(0,0,0,date("m"),date("d")+$i,date("Y")));
$dateForString = date("D d/m/Y", mktime(0,0,0,date("m"),date("d")+$i,date("Y")));
$response .= "<td height='350px' style='color:white; background-color:grey;'>$dateForString</td>";
while($row = mysql_fetch_array($results)){
$id = $row['id'];
$poster = $row['poster'];
$date = $row['date'];
$response .= "$date : $dateCompare<br>";
if($date == $dateCompare){
$response .= "<td><a href='fullinfo.php?selected_id=$id'><img src='$poster' height='350px' /></a></td>";
}
}
}
}
FOLLOWED BY THE SECOND
$response .= "<table><tr>";
if($nit == 0){
for($i = 0; $i < 60; $i++){
$dateCompare = date("Y-m-d", mktime(0,0,0,date("m"),date("d")+$i,date("Y")));
$dateForString = date("D d/m/Y", mktime(0,0,0,date("m"),date("d")+$i,date("Y")));
$response .= "<td height='350px' style='color:white; background-color:grey;'>$dateForString</td>";
$results = mysql_query($query);
while($row = mysql_fetch_array($results)){
$id = $row['id'];
$poster = $row['poster'];
$date = $row['date'];
if($date == $dateCompare){
$response .= "<td><a href='fullinfo.php?selected_id=$id'><img src='$poster' height='350px' /></a></td>";
}
}
}
}
First one results in -it seems - to only go through the while loop once, the first time. So out put is todays date, for the number of results from the database.
The second works fine, prints out in order and matches up. I just don't like its inefficiency.
Thanks
Canty