Friends, help me figure it out.

I have a request:

$result = mysql_query("SELECT * FROM multiplys WHERE sale = '$data_sale[id]'"); $multiply = mysql_fetch_array($result); 

I would like to parse the $ multiply array in another loop like this:

 for($i = 0; $i < 30; $i++) { echo $multiply['0']['title']; } 

Immediately, I note that I need to parse exactly in my cycle, since it processes other data, please do not offer while ($ multiply = mysql_fetch_array (result)), since I need a specific option that I described.

In general, I want to get a two-dimensional array after executing the query to the database and parsing it in this form:

 $multiply['0']['title']; 
  • Well, take mysql_num_rows and run through a cycle from 0 to mysql_num_rows and there you already have to do fetch(result) ... who doesn't give you that? - Alexey Shimansky
  • Well, as an option, yes, what you offer is suitable. Is there a way to first make one request and save it all to a two-dimensional array? - WhoIsDT
  • extracting the results is due to mysql_fetch_array .... you make a mysql_fetch_array cycle for any soul in which you extract values ​​to an array .... - Alexey Shimansky

1 answer 1

If I understood correctly, the same can be done with while in the following way:

 $c = 0; $multiply = []; while($row = mysql_fetch_array($result)) { $multiply[$c] = $row; $c++; }