Hi guys.
I'm still relatively new to php programming and I'm having some problems with some functionality that i am currently writing. I want to capture all the data from my database table and put it in a 2 dimensional array. I found this function online that seems to do the trick:
>function mysql_fetch_data($result, $numass=MYSQL_BOTH) {
$i=0;
$keys=array_keys(mysql_fetch_array($result, $numass));
mysql_data_seek($result, 0);
while ($row = mysql_fetch_array($result, $numass)) {
foreach ($keys as $speckey) {
$got[$i][$speckey]=$row[$speckey];
}
$i++;
}
return $got;
}
the problem i am having is that i want to reference each element within the master array dynamically:
> $result = mysql_query($select, $conn) or die(mysql_error());
$rowcount = mysql_num_rows($result);
$properties = mysql_fetch_data($result);
for($i=1; $i<10; $i++)
{
if($rowcount <= $i)
{
echo('filename: '.$properties[$i]['filename'].'<br />');
}
else
{
//do something else
}
}
why is it that i can not reference that specific index position dynamically? when i replace my variable ($i) with a specific value, the correct value for my field 'filename' is appearing. am i missing something or doing something incorrectly?? any help would be greatly appreciated!
Thanks in advance,
Sam