Do you have a question? Post it now! No Registration Necessary. Now with pictures!
April 17, 2010, 11:20 pm
rate this thread
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
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?
April 19, 2010, 11:35 am
El 18/04/2010 1:20, bipin escribió/wrote:
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.
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.
I'm lost here... Do you want to fetch *all* the rows and then emulate
SQL's WHERE stament with PHP?
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com