User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 360,992 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,563 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser:

help a newbie? mySQL find & replace

Join Date: Aug 2006
Posts: 15
Reputation: kyleknapp is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
kyleknapp kyleknapp is offline Offline
Newbie Poster

Re: help a newbie? mySQL find & replace

  #10  
Oct 12th, 2006
Okay, I'm making progress. The following code
echo "selecting userids for 68104<br>";

$sql = 'SELECT userid FROM `phplist_user_user_attribute` WHERE `attributeid`= 7 AND `value` LIKE "68104"';
$query = mysql_query($sql);

echo mysql_num_rows($query), "rows selected<br>";

if (mysql_num_rows($query)) {
$ary = implode(',', mysql_fetch_assoc($query));
echo $ary, "<br>";
$update = "UPDATE  `phplist_user_user_attribute`  SET  `value`  =  'on' WHERE  `attributeid`  ='16' AND  `userid` IN (".$ary.")";
mysql_query($update);
} 

displays:
selecting userids for 68104
23rows selected
userid: 21

the script is selecting 23 records, but not doing anything with any but the first. I don't think I see anything in the code that causes it to "loop" through the selected records. Is there something comparable to a "DO WHILE" or "LOOP" command I should be inserting somewhere?

Thanks,
~kyle
Reply With Quote  
All times are GMT -4. The time now is 6:25 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC