Your code doesnt do the same thing as mine. The point is I'm taking the result array (which is only one dimension) and iterating through it hundreds of times.
So is it faster just to access a local array with the data in it or to keep calling mysql_fetch_assoc to get the data out of the result array.
$result = mysql_query("SELECT * FROM `rating_fields`");
$x = 0;
while(${"rows".(++$x)} = mysql_fetch_assoc($result)); // or whatever you prefer for your fetch..
to have each row as its own array (two-dimensional):
$result = mysql_query("SELECT * FROM `rating_fields`");
while($row = mysql_fetch_assoc($result)) // or whatever you prefer for your fetch..
foreach($row as $k => $v)
${"$k"}[] = $v;
If you want each field as it's own array (two-dimensional)
$result = mysql_query("SELECT * FROM `rating_fields`");
while($row = mysql_fetch_assoc($result)) // or whatever you prefer for your fetch..
foreach($row as $k => $v)
$data[$k][] = $v;
It's not advisable to use fetch_array in any of those... #3 won't work with fetch_row...