Re: mysql_query > array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




$result = mysql_query("SELECT System_ID, System_name FROM Systems");

/* you can get all systems by this : */

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
       $sysarray[$row[0]]=  $row[1];
       $isselected[$row[0]]=FALSE;
    }

Then

$result = mysql_query("SELECT System_ID,  FROM User_Systems where
User_ID=".$usr_id);  /* usr_id is the particular user you want to show info
about*/

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
       $isselected[$row[0]]=  TRUE;
   }

And now the $sysarray contains system_id and name pairs and $isselected
contains system_id and whether a system is selected by a user or not

HTH

Mustafa Ocak
PHP Developer
Ankara, Turkey


----- Original Message -----
From: "shaun" <shaun@mania.plus.com>
To: <php-db@lists.php.net>
Sent: Thursday, April 17, 2003 1:09 PM
Subject: Re:  mysql_query > array


> any chance of a longer answer ;)
>
> "Matthew Nock" <matthew@mnc.com.au> wrote in message
> DOEEJNAFHHEJMCCGIDPDEELCEDAA.matthew@mnc.com.au">news:DOEEJNAFHHEJMCCGIDPDEELCEDAA.matthew@mnc.com.au...
> > short answer:  yes.
> >
> >
> > -----Original Message-----
> > From: shaun [mailto:shaun@mania.plus.com]
> > Sent: Thursday, 17 April 2003 7:56 PM
> > To: php-db@lists.php.net
> > Subject:  mysql_query > array
> >
> >
> > Hi,
> >
> > is it possible to retreive the contents of a query to an array. The
reason
> i
> > ask is because i have a page which shows a list of sytems held in the
> > Systems table. By each system i have a check box and if the user is
> > competent in that system i want to place a tick in it. This data is
stored
> > in User_Systems with System_ID and User_ID. So what i would like to do
is
> > query the Systems table to get all the systems then query the
User_Systems
> > table and get an array of system_ids. Then whilst drawing the table of
> > checkboxes i can check to see if the system_id for that checkbox is in
the
> > array...
> >
> > Thanks for your help
> >
> >
> >
> > --
> > 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


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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux