Re: extract data from database into an array

From: Date: Sun, 14 Jul 2002 02:56:46 +0000
Subject: Re: extract data from database into an array
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-20536@lists.php.net to get a copy of this message
> I have a database, all the data is numbers. I want to make a query that > will extract the data and then make it available in an array, so the > array is populated 'real-time'. I could just enter the number into an > array manually, but I want to automate the job. I don't know what to > start looking for, the 3 books I have either don't talk about this or I > just am missing it. > Could someone point me in the right direction? Well after you SELECT the data and run the query, you can use a few functions, it depends on your database type? For example, for MySQL, you can use mysql_fetch_array() which will take your data and store it in an array, both numeric and associative. i.e. $data = mysql_fetch_array($result) can be accessed like $data['column_name'] $data[column_number] You can also fetch an array only as an associative (mysql_fetch_assoc) or numeric (mysql_fetch_row). And simply if selecting multiple rows, use a loop while($data = mysql_fetch_array())... -------------- Adam Alkins http://www.rasadam.com --------------

« previous php.db (#20536) next »