I'm not sure, but I thought there was a way to rename variables and/or change them to create additional variables.
Can someone enlighten me?
lets say I grab a query that says the maximum of the season field is 6.
I run a loop loops through 6 times, running 6 seperate queries.
These queries grab all the rows that have season fields that are the same number as the loop's number.
I need variable for each query.
But I can't create these variables manually, because I don't know how many queries will run.
you can create an array variable like this
$xyz = array();
lets assume a loop
while(condition)
{
$xyz[ ] = /* store the retrieved value */
}
in order to retrieve the value
use foreach( $xyz as $value) syntax
or u can refer normally as $xyz[i] also if you want to know the length of the array use the function count($xyz)
I hope this work or else please provide you syntax so that I can figure out some possible solution
well seeing that each querie is also something like an array.
It's not just one result the querie is returning. It's collection of rows.
Since normally you refer to it's rows in a foreach loop
"foreach ($variable as $variable)"
and you call a field
"$variable->fieldname"
this is why I had both a for, and a foreach.
One to loop through the first array (which used the seasonCount that is par to the array count,) the foreach was my attempt to loop through the inner array (loop through the query.)
Yes can put array in an array. Hope this will solve your problem
<?php
foreach ($sArray as $value)
foreach ($value as $value1)
echo '<div>'.$value1. '</div>';
?>
Bookmarks