Re: [PHP] Getting mysql_query results into an array



At 6:22 PM -0600 2/13/07, Richard Lynch wrote:


The most efficient way is "Don't do that." :-)

Simply loop through the results and do whatever you want to do with
them, and don't put them into an array at all.

This question has appeared before, and usually breaks down to one of
these scenarios:

#1

snip 1


#2

snip 2


#2 does occasionally have an exception to the rule, where the SQL
query is nasty and the PHP is fast and easy, but that's awfully rare.



How about scenario #3: I wish to output my data in (for example) three columns, as a phone book does. To make the example simple, assume 15 data points. I wish the output to look like

1 6 11
2 7 12
3 8 13
4 9 14
5 10 15

So when I'm outputting row 1, I need data points 1, 6, and 11. Isn't it easier to generate the query, put in array, and output the rows from the array? Keep in mind, the number of data points might be variable, the constraints being n columns with approximately the same number of data point in each column.

-----===== Bill =====-----
--

The secret of life is...I can't tell you. It's a secret.
.



Relevant Pages

  • RE: Array Help
    ... Dim strSQL As String ... the Access "INSERT INTO" SQL query is: ... one field is changed for each query, I was thinking that I could loop though ... I am not sure how to do a loop through the array or write any code for it as ...
    (microsoft.public.access.modulesdaovba)
  • Re: Copying a table to an array
    ... You probably don't need a query, ... Dim rstRSet As Recordset ... table to enable data from the latter to be read into an array with GetRows. ... exercise has therefore to be repeated prior to each interrogation. ...
    (microsoft.public.access.formscoding)
  • Re: Mix/Max/Avg Help based on dynamic ranges
    ... Did you enter Biff's formula as an array? ... The query I gave you is dependent on your breaking out the ranges as Biff ... Where Nums are the values to avg based on the head count range. ... deemed optimal for building device profiles based on locn size and device ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Need Help With Pivot/Cross-Tab Query Please/ **Dates Are Not Fixed**
    ... I was able to get the pivot-like query to work. ... and loop in the QUERY's SELECT statement that returns the "AS Day1, ... Used another CF array and loop to get the column headers to print the ... variables when outputting the query results to a report, ...
    (microsoft.public.sqlserver.programming)
  • Re: Copying a table to an array
    ... "Peter Hibbs" wrote: ... You probably don't need a query, ... Dim rstRSet As Recordset ... table to enable data from the latter to be read into an array with GetRows. ...
    (microsoft.public.access.formscoding)