Re: Can you l put a mysql statement in a while loop?

From: Date: Fri, 27 Oct 2000 16:37:24 +0000
Subject: Re: Can you l put a mysql statement in a while loop?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-22349@lists.php.net to get a copy of this message
actually this is not a bug of php look this description of mysql_query found in the mysql api description: >20.4.39 mysql_query() >int mysql_query(MYSQL *mysql, const char *query) >20.4.39.1 Description >Executes the SQL query pointed to by the null-terminated string query. The query must consist of a single SQL statement. You should not add >a terminating semicolon (`;') or \g to the statement. Eric ----- Original Message ----- From: "Maxim Maletsky" <maxim.maletsky@japaninc.net> To: "'Jan-Eric Duden'" <duden@uwyo.edu>; "Dallas Kropka" <dallask@firstworld.net>; <php-general@lists.php.net> Sent: Friday, October 27, 2000 2:14 AM Subject: RE: [PHP] Can you l put a mysql statement in a while loop? > Because I think it's a bug I submitted it into PHP Bugs. > Hope someday it will work! > > Just think how useful it can be.. > > -----Original Message----- > From: Jan-Eric Duden [mailto:duden@uwyo.edu] > Sent: Friday, October 27, 2000 4:15 PM > To: Dallas Kropka; php-general@lists.php.net > Subject: Re: [PHP] Can you l put a mysql statement in a while loop? > > > sorry about that ... > it works on the mysql prompt and with phpMyAdmin (probably they generate > multiple queries,too) > but not with with mysql_query :( > > only your example will work > > ill need some sleep :) > Eric > > ----- Original Message ----- > From: "Dallas Kropka" <dallask@firstworld.net> > To: "Jan-Eric Duden" <duden@uwyo.edu> > Sent: Friday, October 27, 2000 3:06 AM > Subject: Re: [PHP] Can you l put a mysql statement in a while loop? > > > > Ah.... will that work tho? having multiple updates strings in a query like > > that? > > > > > > ----- Original Message ----- > > From: "Jan-Eric Duden" <duden@uwyo.edu> > > To: "Dallas Kropka" <dallask@firstworld.net>; "Shane McBride" > > <php@riversidedesigns.net>; "Php-General" > > <php-general@lists.php.net> > > Sent: Thursday, October 26, 2000 11:49 PM > > Subject: Re: [PHP] Can you l put a mysql statement in a while loop? > > > > > > > no... > > > > > > you missed the little point in the statement : > > > > > $statement.="UPDATE table SET value=$v WHERE id=$id;"; > > > ^ > > > thus the result of the while loop will be for example: > > > $statement== > > > "UPDATE table SET value=a WHERE id=2;UPDATE table SET value=b WHERE > > > id=3;UPDATE table SET value=c WHERE id=4;UPDATE table SET value=d WHERE > > > id=5;UPDATE table SET value=e WHERE id=6;" > > > > > > > > > Eric > > > > > > > Thats not gona do it.... you wont get your results like that. > > > > > > > > what you need is this. > > > > > > > > > > > > while(list($id,$v)=each($myarray)) > > > > { > > > > $statement="UPDATE table SET value=$v WHERE id=$id;"; > > > > $result=mysql_query($statement); > > > > > > > > } > > > > > > > > > > > > ----- Original Message ----- > > > > From: "Jan-Eric Duden" <duden@uwyo.edu> > > > > To: "Shane McBride" <php@riversidedesigns.net>; > > > > "Php-General" > > > > <php-general@lists.php.net> > > > > Sent: Thursday, October 26, 2000 11:27 PM > > > > Subject: Re: [PHP] Can you l put a mysql statement in a while loop? > > > > > > > > > > > > > What about this here? > > > > > > > > > > $statement=""; > > > > > while(list($id,$v)=each($myarray)) > > > > > { > > > > > $statement.="UPDATE table SET value=$v WHERE id=$id;"; > > > > > } > > > > > > > > > > $result=mysql_query($statement); > > > > > > > > > > Eric > > > > > > > > > > ----- Original Message ----- > > > > > From: "Shane McBride" <php@riversidedesigns.net> > > > > > To: "Php-General" <php-general@lists.php.net> > > > > > Sent: Thursday, October 26, 2000 9:19 PM > > > > > Subject: [PHP] Can you l put a mysql statement in a while loop? > > > > > > > > > > > > > > > I have an array that contains new values for a table. Can I use an > > > > "update" > > > > > statement in a while loop? > > > > > > > > > > I seems like a lot of overkill and waste of resources. > > > > > > > > > > Any better ideas (heck, ideas that will work would be cool). > > > > > > > > > > Nothing found elsewhere... > > > > > > > > > > TIA, > > > > > Shane > > > > > > > > > > > > > > > > > > > > -- > > > > > PHP General Mailing List (http://www.php.net/) > > > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > > > > For additional commands, e-mail: php-general-help@lists.php.net > > > > > To contact the list administrators, e-mail: > > php-list-admin@lists.php.net > > > > > > > > > > > > > > > > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#22349) next »