Thanks! This is starting to make sense...although when I try to
reset what I thought was my array, I get the "Variable passed to
reset() is not an array or object" error message. Here's the
relevant code:
$relationsquery = "select * from relations where
childtype='$childtype' and parenttype='$parenttype' and
parentsku='$parentsku'";
$relationsresult = mysql_query($relationsquery) or die(mysql_error());
while ($relationsrow = mysql_fetch_array($relationsresult)) {
$thischild = $relationsrow["childsku"];
if ($thevalue == $thischild) {
echo " checked";
}
} // end while for relations loop
reset($relationsresult);
Thanks again for your help so far!
Maurice
At 2:00 PM -0800 1/17/01, Rasmus Lerdorf wrote:
>> > What I'm getting is that the inner while loop executes on the first
>> > execution of the outer while, and then not at all. How would I get
>> > it to execute each time?
>>
>> Coming from a perl background, I got stuck there too when I started using
>> PHP. PHP has this odd notion of an array pointer. After the first time you
>> loop through the array, the pointer is at the end, so the second loop won't
>> really do anything. Use the reset frunction to reset the array pointer to
>> the first element.
>
>The array pointer can be pretty useful. ie. give me the second last
>element of an array:
>
> end($arr);
> echo prev($arr);
>
>Or have it tell you what the index is at the second last element:
>
> end($arr);
> prev($arr);
> echo key($arr);
>
>and the index before that one:
>
> prev($arr);
> echo key($arr);
>
>Perl has these too, they just aren't user accessible.
>
>-Rasmus
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
Maurice Rickard
http://mauricerickard.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]