Re: select into array

From: Date: Wed, 16 Jan 2002 13:48:19 +0000
Subject: Re: select into array
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-15876@lists.php.net to get a copy of this message
George, Whether you can select into an array directly depends on your database. In any case, PHP executes database queries and returns a handle or container which is accessed as an array. Here's the example from http://www.php.ca/manual/en/function.mysql-fetch-array.php <?php mysql_connect($host, $user, $password); mysql_select_db("database"); $result = mysql_query("select user_id, fullname from table"); while ($row = mysql_fetch_array($result)) {
    echo "user_id: ".$row["user_id"]."<br>\n";
    echo "user_id: ".$row[0]."<br>\n";
    echo "fullname: ".$row["fullname"]."<br>\n";
    echo "fullname: ".$row[1]."<br>\n";
} mysql_free_result($result); ?> If you want a tutorial on this, Julie Meloni has some really good examples at http://www.thickbook.com and there are others at DevShed and WebMonkey. Cheers - Miles At 02:42 PM 1/16/2002 +0200, George Lioumis wrote:
Hello everyone! I have the following table: |name |-------------- |n_id |n_name |ns_id --------------- I do a select: "SELECT n_name from name" and I want to put all selected "n_name" values into an array (say it names) How can this be done?? Thanx in advance.


« previous php.db (#15876) next »