Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

hi i am trying to build a reporting engine.  i have just created the
equivalent using ms access. but am need of a multi user web version.

in access i used recordsets that were returned from a SQL query;
then would traverse that recordset using the 'seek' or 'findfirst'
build a temporary table then output a report from that temp table.

i am having trouble about how to approach this in php.  i get the
from my query, but am having trouble using that information to build
temp table.  from what i can tell the function mysql_fetch_assoc()
a bunch of one dimensional arrays.  but i need a two dimensional array
to hop up and down looking for dates and then returning the sales,
etc.. to build my temp table for the report.

it is my understanding that a recordset in simply a two dimensional
is this right?  if so do i need to array_merge() all the one
dimensional arrays
from mysql_fetch_assoc() into a 2d array? then use array_search() to
the values that correspond to the correct dates??

i'm not sure if i am approaching this correctly.  any suggestions?

thanks alot,

Re: recordsets

Quoted text here. Click to load it

I can't necessarily see the need for a temporary table here. I would
tend to do all this stuff in SQL and then just use the result set.

I think you would do better to offer a description of the database
part of this application over in comp.databases.mysql and ask for help

Re: recordsets

El 18/04/2010 1:20, bipin escribió/wrote:
Quoted text here. Click to load it

The way you say it suggest that you might be guessing from trial and
error... All this stuff is documented at:

    (PHP 4 >= 4.0.3, PHP 5)
    mysql_fetch_assoc — Fetch a result row as an associative array

The left column shows an overview of all available functions.

Quoted text here. Click to load it

I believe you are slightly confused.

First of all, PHP doesn't have a unique centralized interface to access
databases. Instead, you have lots of extensions and each extension has
its own API and philosophy.

Secondly, you are using the regular MySQL functions (yep, there're some
other ways to use MySQL from PHP, this is only one of them) and this
extension doesn't have the concept of recordset. You run a query against
the database server, typically with mysql_query(), and you get back a
resource identifier. You then use this identifier with the function you
prefer: mysql_fetch_array(), mysql_fetch_assoc(), mysql_ fetch_object(),
mysql_num_rows()... You'll get whatever the chose function returns but,
in general, you don't have a single object that holds all the rows: you
fetch rows one by one as you need them. Some times you store values in
variables to use them later, sometimes you process them on the fly.

Quoted text here. Click to load it

I'm lost here... Do you want to fetch *all* the rows and then emulate
SQL's WHERE stament with PHP?

-- - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:
-- Mi web de humor satinado:

Site Timeline