Re: [PHP] how to extract fields from associative array into different variables

2009-06-18 Thread PJ
ono ato sekai desu. > > > > >> To: php-general@lists.php.net >> From: news.nospam.0ixbt...@luden.se >> Date: Thu, 18 Jun 2009 14:17:59 +0200 >> Subject: Re: [PHP] how to extract fields from associative array into >> different variables >> >>

Re: [PHP] how to extract fields from associative array into different variables

2009-06-18 Thread Eddie Drapkin
of > associative array) in a variable $row. > > Yuri Yarlei. > Programmer PHP, CSS, Java, PostregreSQL; > Today PHP, tomorrow Java, after the world. > Kyou wa PHP, ashita wa Java, sono ato sekai desu. > > > >> To: php-general@lists.php.net >> From: news.nospam.0i

Re: [PHP] how to extract fields from associative array into different variables

2009-06-18 Thread PJ
Nisse Engström wrote: > On Tue, 16 Jun 2009 08:50:45 -0400, PJ wrote: > > >> Ashley Sheridan wrote: >> >>> On Mon, 2009-06-15 at 17:38 -0400, PJ wrote: >>> >>> Then I have to add some loopy thing to assign the values to the $variables... a real pita since my variable do

RE: [PHP] how to extract fields from associative array into different variables

2009-06-18 Thread Yuri Yarlei
: php-general@lists.php.net > From: news.nospam.0ixbt...@luden.se > Date: Thu, 18 Jun 2009 14:17:59 +0200 > Subject: Re: [PHP] how to extract fields from associative array into > different variables > > On Tue, 16 Jun 2009 08:50:45 -0400, PJ wrote: > > > Ashley Sheridan wrote

Re: [PHP] how to extract fields from associative array into different variables

2009-06-18 Thread Nisse Engström
On Tue, 16 Jun 2009 08:50:45 -0400, PJ wrote: > Ashley Sheridan wrote: >> On Mon, 2009-06-15 at 17:38 -0400, PJ wrote: >> >>> Then I have to add some loopy thing to assign the values to the >>> $variables... a real pita since my variable do not lend themselves too >>> well to linear alterations

Re: [PHP] how to extract fields from associative array into different variables

2009-06-16 Thread PJ
Ford, Mike wrote: > On 15 June 2009 18:07, PJ advised: > > >> Is there an easier or simpler way to do this? >> code: >> >> $sql = "SELECT first_name, last_name, book_author.ordinal >> FROM author, book_author >> WHERE book_author.bookID = $idIN && book_author.authID = >> > autho

RE: [PHP] how to extract fields from associative array into different variables

2009-06-16 Thread Ford, Mike
On 16 June 2009 13:58, PJ advised: > Ford, Mike wrote: >> On 15 June 2009 18:07, PJ advised: >> >> >>> Is there an easier or simpler way to do this? >>> code: >>> >>> $sql = "SELECT first_name, last_name, book_author.ordinal >>> FROM author, book_author >>> WHERE book_author.bookID

Re: [PHP] how to extract fields from associative array into different variables

2009-06-16 Thread Eddie Drapkin
And, assuming the same table (just got the new email, sorry) for the update: function makeUpdateQuery(array $authors, $bookId) { foreach($authors as &$author) { $author = mysql_real_escape_string($author); } if(!ctype_digit($bookId)) { return false; } $existing = array(); $getAuthors = 'SEL

Re: [PHP] how to extract fields from associative array into different variables

2009-06-16 Thread Eddie Drapkin
I'm going to assume that your table is setup to have the rows BookID and AuthorName, adjust accordinging: function makeInsertQuery(array $authors, $bookId) { $sql = "INSERT INTO book_authors (BookID, AuthorName) VALUES ('$bookId', '"; foreach($authors as &$author) { $author = mysql_real_esca

Re: [PHP] how to extract fields from associative array into different variables

2009-06-16 Thread PJ
Ford, Mike wrote: > On 15 June 2009 18:07, PJ advised: > > >> Is there an easier or simpler way to do this? >> code: >> >> $sql = "SELECT first_name, last_name, book_author.ordinal >> FROM author, book_author >> WHERE book_author.bookID = $idIN && book_author.authID = >> > autho

Re: [PHP] how to extract fields from associative array into different variables

2009-06-16 Thread PJ
Ashley Sheridan wrote: > On Mon, 2009-06-15 at 17:38 -0400, PJ wrote: > >> Jay Blanchard wrote: >> >>> [snip] >>> In what way would this simplify or ease my pain? >>> The difficulty, it seems to me, is not in retrieving the rows, but >>> rather how to pass the row data to the variables. And

RE: [PHP] how to extract fields from associative array into different variables

2009-06-16 Thread Ford, Mike
On 15 June 2009 18:07, PJ advised: > Is there an easier or simpler way to do this? > code: > > $sql = "SELECT first_name, last_name, book_author.ordinal > FROM author, book_author > WHERE book_author.bookID = $idIN && book_author.authID = author.id > ORDER BY ordinal"; > > $autho

Re: [PHP] how to extract fields from associative array into different variables

2009-06-16 Thread kranthi
you dont have an alternative. you will have to loop because mysql_fetch_* functions fetch only one row at a time. you can use variable variables to achieve the above result (you will not require this if u use list() or extract() functions) http://us.php.net/manual/en/language.variables.variable.ph

Re: [PHP] how to extract fields from associative array into different variables

2009-06-15 Thread Ashley Sheridan
On Mon, 2009-06-15 at 17:38 -0400, PJ wrote: > Jay Blanchard wrote: > > [snip] > > In what way would this simplify or ease my pain? > > The difficulty, it seems to me, is not in retrieving the rows, but > > rather how to pass the row data to the variables. And since the number > > of rows is variab

Re: [PHP] how to extract fields from associative array into different variables

2009-06-15 Thread PJ
Jay Blanchard wrote: > [snip] > In what way would this simplify or ease my pain? > The difficulty, it seems to me, is not in retrieving the rows, but > rather how to pass the row data to the variables. And since the number > of rows is variable, I believe that the only way to assign the variables >

RE: [PHP] how to extract fields from associative array into different variables

2009-06-15 Thread Jay Blanchard
[snip] In what way would this simplify or ease my pain? The difficulty, it seems to me, is not in retrieving the rows, but rather how to pass the row data to the variables. And since the number of rows is variable, I believe that the only way to assign the variables is by use of a loop? I think I'm

Re: [PHP] how to extract fields from associative array into different variables

2009-06-15 Thread Eddie Drapkin
You could use list() a la list($foo, $bar) = mysql_fetch_row(); On Mon, Jun 15, 2009 at 4:19 PM, PJ wrote: > Jay Blanchard wrote: > > [snip] > > Is there an easier or simpler way to do this? > > [/snip] > > > > http://us2.php.net/manual/en/function.mysql-fetch-row.php > > > In what way would thi

Re: [PHP] how to extract fields from associative array into different variables

2009-06-15 Thread PJ
Jay Blanchard wrote: > [snip] > Is there an easier or simpler way to do this? > [/snip] > > http://us2.php.net/manual/en/function.mysql-fetch-row.php > In what way would this simplify or ease my pain? The difficulty, it seems to me, is not in retrieving the rows, but rather how to pass the row d

RE: [PHP] how to extract fields from associative array into different variables

2009-06-15 Thread Jay Blanchard
[snip] Is there an easier or simpler way to do this? [/snip] http://us2.php.net/manual/en/function.mysql-fetch-row.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] how to extract fields from associative array into different variables

2009-06-15 Thread PJ
Is there an easier or simpler way to do this? code: $sql = "SELECT first_name, last_name, book_author.ordinal FROM author, book_author WHERE book_author.bookID = $idIN && book_author.authID = author.id ORDER BY ordinal"; $author = array(); if ( ( $results = mysql_query($sql, $