Basically, the "mysql_query" submits the sql statement
to the database engine, and the "mysql_fetch_array"
allows retrieval of selected information returned from
the query into an associative array with each columnname
of the query an associative "key" in the array ....
Example...
--login-to-host-and-db-connectors-here--
$sql = "select name, address, city, state, zip ";
$sql .= "from addressbook ";
$sql_result = mysql_query($sql) or die ("bad SQL [$sql]");
--print beginning html table tags and first row headers here---
while($data_row = mysql_fetch_array($sql_result))
{
$sel_name = $data_row["name"];
$sel_address = $data_row["address"];
$sel_city = $data_row["city"];
$sel_state = $data_row["state"];
$sel_zip = $data_row["zip"];
// my personal preference is to use simple fields for
// display purposes. I could have easily used the
// array names as well... such as $data_row["name"] for $sel_name
echo("<tr><td>$sel_name</td>");
echo("<td>$sel_address</td>");
echo("<td>$sel_city</td>");
echo("<td>$sel_state</td>");
echo("<td>$sel_zip</td></tr>");
}
--print closing html table tags---
> -----Original Message-----
> From: Dibo Chen [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 09, 2002 11:45 AM
> To: Alex Shi
> Cc: [EMAIL PROTECTED]
> Subject: Re: How Query and Fetch work?
>
>
> When you are told to fill in fuel and turn the key to drive, I suppose
> you don't care how the fuel runs the car. Do the same things
> in any lib
> you use, pushing the "buttons" in told order would work.
> Well, you may
> dig deeper if you like since the code is available.
>
> Alex Shi wrote:
> >
> > Yesterday I posted a question yet got response. The question
> > is regarding to how Query works. Now I repost it in a more
> > specific way.
> >
> > I am just wondering how MySQL API functions work. Let's look
> > at following two functions:
> >
> > 1. mysql_query(),
> > 2. mysql_fetch_array()
> >
> > To my understanding, mysql_query() will definately to its job with
> > MySQL server. But how about the latter? Does it just fetch data
> > from client/local buffer, which is previously put in by
> mysql_query(),
> > or still has to goto server side to fetch data?
> >
> > Alex
> >
> >
> ---------------------------------------------------------------------
> > Before posting, please check:
> > http://www.mysql.com/manual.php (the manual)
> > http://lists.mysql.com/ (the list archive)
> >
> > To request this thread, e-mail <[EMAIL PROTECTED]>
> > To unsubscribe, e-mail
> <[EMAIL PROTECTED]>
> > Trouble unsubscribing? Try:
http://lists.mysql.com/php/unsubscribe.php
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php