OK, then.  Here's an example.  I understand that this is confusing (it took
me quite some time to get my first db example working correctly), but there
are normally examples on PHP.net if you look up the functions that Jason
referred you to.  If those didn't help I don't know how much help mine will
be, but at least I kind of explain it :-)

It's using Sybase, but the commands should be very similar to those for
other ones (I think all that changes is the first part).

For mine, here's how I set up $sql:
$countySql = "SELECT a.Sex, a.AgeForCSR, a.Pop, b.strAgeForCSRDescription, 1
as id from tblPopCounty a, tlkpAgeForCSR b where a.StateFIPS = '$state' and
a.CountyFIPS = '$county' and a.Race = '$race' and a.$sqlAge and

$stateSql =  "SELECT a.Sex, a.AgeForCSR, a.Pop, b.strAgeForCSRDescription, 2
as id from tblPopState a,  tlkpAgeForCSR b where a.StateFIPS = '$state' and
a.Race='00' and a.$sqlAge and a.AgeForCSR=b.AgeForCSR";

$sql = $countySql . " UNION " . $stateSql;

$array_ref[0] = Sex
$array_ref[1] = AgeForCSR
$array_ref[2] = Pop
$array_ref[3] = strAgeForCSRDescription
$array_ref[4] = id

***Here's where I actually read the rows that are identified by the result
and divide them up into 4 arrayes, based on gender and id***
$dataResult = sybase_query($sql);
while ($array_ref = sybase_fetch_row($dataResult)) {    
        //foreach ($a_row as $array_ref) { *** if you leave that in, you get
each item, not each row***
                //print $array_ref . "<BR>";
                if ($array_ref[4] == 1) {
                        if ($array_ref[0] == $male ) {  
                                $left[$i] = $array_ref[2];
                                $names[$i] = $array_ref[3];
                                $ages[$i] = $array_ref[1];
                        elseif ($array_ref[0] == $female ) { 
                                $right[$j] = $array_ref[2];
                elseif ($array_ref[4]==2) {
                        if ($array_ref[0] == $male ) {  
                                $left2[$k] = $array_ref[2];
                                $names2[$k] = $array_ref[3];
                                $ages2[$k] = $array_ref[1];
                        elseif ($array_ref[0] == $female ) { 
                                $right2[$l] = $array_ref[2];
                }//elseif id==2 
//      }//foreach

-----Original Message-----
From: Jas [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, May 30, 2002 1:27 PM
Subject: Re: [PHP-DB] how to pull array out?

Mr. Wong,
    You are no help.  As you can probably see I am NOT an experienced php
developer!!  Posting to this list, reading the manual, and scouring sites
for tutorials is all I have to provide me with a way to maybe begin doing
writting php apps.  I did read your reply about "feeding the results into an
array"  however I have not been able to accomplish what I have set out to
do.  A GOOD EXPLANATION IS ALL WE NEED!!! You posting stuff on how we should
read the manual does not suffice!  People post to this newsgroup to get
answers to problems they cannot figure out.  I am sure you have been working
with php enough to know how to accomplish anything you need, and for the
rest of us we rely on examples, etc to get it done.  I appriciate you taking
the time to reply to mine and others posts, however if you do not have
anything nice to say please keep it to yourself.  I am trying to find an
answer to a problem and reading your RTFM does not help.  Thannks again, Jas

"Jason Wong" <[EMAIL PROTECTED]> wrote in message
> On Friday 31 May 2002 00:19, Jas wrote:
> > Not sure how to do this, but I need to pull the contents of an array
> > editable text fields...  As of yet I have not found a way to 
> > accomplish
> > this:
> Good grief, I already posted the answer yesterday. Don't you read the
> Even if you don't, spending a little time googling for "mysql php
> would get you numerous examples.
> > $table = "auth_users";
> >  $record = @mysql_query("SELECT * FROM $table WHERE user_id = 
> > '$user_id'",$dbh);
> [snip]
> >     echo $record;
> >
> > It only echoes the resource id, any help or examples would be 
> > great!!!!
> I repeat, mysql_query() returns a resource-id which you need to feed 
> into
> mysql_fetch_array() to get the actual record.
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development 
> *
> /*
> The chief danger in life is that you may take too many precautions.
> -- Alfred Adler
> */

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to