K, here is the deal. I am trying to populate a multidimensional array, eventually with data from several queries. I can't give you the full perfected code because I'm still working on patchy code that doesn't work yet. Here is the idea though. This example just assumes we are using one query. The below example is sort of what I tried for multiple queries. I gotta get the two dimension working first.
$result = mysql_query($query);
$num_rows = mysql_num_rows($results);
$row = mysql_fetch_row($results);
$num_fields = sizeof($row);
$final = array();
for ($i = 0; $i < $num_rows; $i++){
$final[$i] = $i;
for ($ii = 0; $ii < $num_fields; $ii++){
$final[$i][$ii] = $row[$ii];
}
}
Okay that is an idea of what I am trying to do. I want to take to query results and stick the row number in the first dimension of the array. Then I want to take the actual field data and insert it into the second dimension of the array so that I can access the data by row and than fields. I'm just not sure what goes where. To me this also could be a possibility...
for ($i = 0; $i < $num_rows; $i++){
for ($ii = 0; $ii < $num_fields; $ii++){
$final[$i][$ii] = $row[$ii];
}
}
I just don't know. And none of them seem to work. Eventually I plan to have an array of sql queries, not just one query to work with. So I would be adding another dimension as well. One where I could access the data first by which query it was to began with, then the row of that query and than the field of that row.
for ($i = 0; $i < $query_num; $i++){
$final[$i] = $i
for ($ii = 0; $ii < $num_rows; $ii++){
$final[$i][$ii] = $ii;
for ($iii = 0; $iii < $num_fields; $iii++){
$final[$i][$ii][$iii] = $row[$iii];
}
}
}
I hope I'm making some since. There could be an altogether better way to do this. Each query differs so I have to think of a way to do it where I don't have to hard code any field name etc.
Thanks for the help, if you need any more info let me know.
Pahikua