needsomehelp
02-12-2013, 04:52 PM
For some reason I am unable to get all of the results in $getResults
In the code below I have commented what the output is for the lines that do output.
The
foreach($results as $result) {
should be going through each of the 48 results, but only does one of them and stops.
I can not figure out why it is missing the rest of them, even though the first output shows that there are 48 to do.
Can anyone spot what I maybe doing wrong ?
$getResults = db_query($mysqli, "SELECT `photos` FROM `items` WHERE `photos` != ''");
// 48 results are returned if i enter the query directly in to phpmyadmin.
print_r($getResults);
// mysqli_result Object ( [current_field] => 0 [field_count] => 1 [lengths] => [num_rows] => 48 [type] => 0 ) Array ( [photos] => 123456.jpg|| )
// correct
$results = $getResults->fetch_assoc();
echo("<br><br><br>:");
print_r($results); // Array ( [photos] => 123456.jpg|| )
echo(":<br>");
// SHOULD BE SHOWING ALL RESULTS IN THE RETURNED RESULTS ARRAY. BUT ONLY SHOWS ONE.
$exist_imgs = glob('/home/****/public_html/images/L*.jpg');
$exist_tn = glob('/home/****/public_html/images/S*.jpg');
$missing_imgs = "";
?><br><br>
total<br>
db=<? echo($getResults->num_rows); ?><br>
img=<? echo(count($exist_imgs)); ?><br>
tn=<? echo(count($exist_tn)); ?><br><br>
// check each image in DB and remove from the arrays if imgs and tn exist.
foreach($results as $result) {
$photos = explode("||", $result);
foreach($photos as $key) {
if ($key) {
echo("testing: ". $key . "<br><br>");
// Check if TN or Pid exists.
$tn_id_Exists = file_exists("/home/****/public_html/images/S" . $key . "");
if ($tn_id_Exists) {
// remove entry for this image as it exists.
} else {
$missing_imgs .= "S" . $key . "<br>";
}
$img_id_Exists = file_exists("/home/****/public_html/images/L" . $key . "");
if ($img_id_Exists) {
// remove entry for this image as it exists.
} else {
$missing_imgs .= "L" . $key . "<br>";
}
}
}
?><br>----------------------------------<br><?
}
In the code below I have commented what the output is for the lines that do output.
The
foreach($results as $result) {
should be going through each of the 48 results, but only does one of them and stops.
I can not figure out why it is missing the rest of them, even though the first output shows that there are 48 to do.
Can anyone spot what I maybe doing wrong ?
$getResults = db_query($mysqli, "SELECT `photos` FROM `items` WHERE `photos` != ''");
// 48 results are returned if i enter the query directly in to phpmyadmin.
print_r($getResults);
// mysqli_result Object ( [current_field] => 0 [field_count] => 1 [lengths] => [num_rows] => 48 [type] => 0 ) Array ( [photos] => 123456.jpg|| )
// correct
$results = $getResults->fetch_assoc();
echo("<br><br><br>:");
print_r($results); // Array ( [photos] => 123456.jpg|| )
echo(":<br>");
// SHOULD BE SHOWING ALL RESULTS IN THE RETURNED RESULTS ARRAY. BUT ONLY SHOWS ONE.
$exist_imgs = glob('/home/****/public_html/images/L*.jpg');
$exist_tn = glob('/home/****/public_html/images/S*.jpg');
$missing_imgs = "";
?><br><br>
total<br>
db=<? echo($getResults->num_rows); ?><br>
img=<? echo(count($exist_imgs)); ?><br>
tn=<? echo(count($exist_tn)); ?><br><br>
// check each image in DB and remove from the arrays if imgs and tn exist.
foreach($results as $result) {
$photos = explode("||", $result);
foreach($photos as $key) {
if ($key) {
echo("testing: ". $key . "<br><br>");
// Check if TN or Pid exists.
$tn_id_Exists = file_exists("/home/****/public_html/images/S" . $key . "");
if ($tn_id_Exists) {
// remove entry for this image as it exists.
} else {
$missing_imgs .= "S" . $key . "<br>";
}
$img_id_Exists = file_exists("/home/****/public_html/images/L" . $key . "");
if ($img_id_Exists) {
// remove entry for this image as it exists.
} else {
$missing_imgs .= "L" . $key . "<br>";
}
}
}
?><br>----------------------------------<br><?
}