Re: MySql help #1

From: Date: Thu, 02 Aug 2001 10:31:34 +0000
Subject: Re: MySql help #1
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-60872@lists.php.net to get a copy of this message
Someone purchased items from my site let's say 3 items out of 5 total. All items are the same. I just want to update 3 items status to "Reserved". When he buy he just tell how many and not which ones. "Lawrence Sheed" <Lawrence.Sheed@dfait-maeci.gc.ca> wrote in message news:4B0FC61A2044D31180A60000F810DF207D3647@shngir01.shngi.dfait-maeci.gc.ca ... > Sounds like a strange request, what are you trying to do? > > I don't think you can do this directly in mysql, but you could build an > array of results in php. > > eg something like (crappy code below) > > //Grab results > $db = mysql_connect($db_domain, $db_user,$db_password); > mysql_select_db($db_databasename,$db); > $sqlquery="select ID from table1 where condition1"; > $result = mysql_query ($sqlstring,$db); > $count=0; > while ($resultset = mysql_fetch_array ($result)) { > $array[$count]=$resultset ["ID"]; > $count++; > } > > > for ($count=0;$count<2;$count++){ > "update table1 set field='VALUE' WHERE ID=".$array[$count]"; > $result = mysql_query ($sqlstring,$db) or die (mysql_error()); > } > > -----Original Message----- > From: elias [mailto:elias_bachaalany@yahoo.com] > Sent: August 2, 2001 4:30 PM > To: php-general@lists.php.net > Subject: [PHP] MySql help #1 > > > How can I update only N fields from the database? > > usually we do: > > UPDATE table1 SET field='VALUE' WHERE condition1 > > now I want to update fields with a certain condition but only X fields out N > total fields. > > ie: > > id value > --- ------- > 1 a > 2 b > 3 c > 4 d > 5 e > > how can i update such like: > UPDATE table1 SET {only 2 records} value='aa' > so I have any two fields now have the 'aa' value > > > > > > -- > 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 (#60872) next »