hello - i need to ask a desparate question: How do I access the values of an array after the array has been traversed using a loop? I tried using reset() but no luck. Also, I'm really confused because this code successfully handles my $result array, yet I cannot access any of its elements for
debugging puposes. But I can access $mywhere_array elements just fine. This makes no sense to me. I'm really hoping someone can shed some light onto my php darkness. Thanks in advance for any help!
Aaron
My problem is (hopefully) an easy one:
// the following code successfully takes multiple selections from the previous form and assigns each value to a $mywhere_array element.
$mywhere_array = array();
while (list($key,$value) = each($sections)) {
array_push($mywhere_array, $value);
}
// this code succesfully queries each value of the multiple select and assigns them each to a $result element.
$name_count = count($mywhere_array);
for ($i=0;$i<=$name_count;$i++) {
$result[$i] = mysql_query ("select * from camera_general where model_name =
'$mywhere_array[$i]'");
}
// this code successfully generates a column for every record in the query. My problem is when I try to use this same code again for each remaining row, I have to do a separate sql call for it to work. reset() doesn't work. Since I have 200+ rows and ~150 records, doing a separate call to the db
for each cell would not be wise. Can someone please shed some light as to how I can perform the following code on each row without performing a SELECT statement for each one?
<?
$irow = 0;
reset($result);
for ($j=0;$j<=$name_count;$j++) {
while ($myrow[$irow] = mysql_fetch_array($result[$j])) {
if ($myrow[$irow][model_name] == "")
$myrow[$irow][model_name] = ' ';
}
?>
<td><b><?=$myrow[$irow][model_name];?></b></td>
<?
++$irow;
}
}
?>