Topic: update all results in a table (Read 1683 times)
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 884
1636 credits Members referred : 4
« on: Sep 12, 2006, 08:46:55 PM »
ok so what im doing THIS time is i have it set so you are able to update a persons data by clicking a link, update. this is ok, and it works fine except when we have 30+ users it can be a hassle to go through each one and click update, so i want to make a master update link that can update ALL results instead just the one you chose, here is the code I use to update a persons data via the link, commands.php?cmd=update&player_id=(some#). i simply want to add a new function to this commands page, update_all and in this case it wouldnt use a particular player ID to do the update, it selects all player names (player_name WHERE player_id = all?) from the table and then updates all of them (and i know this will be a big page most likely and take a while to parse/execute, thats understandable).
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 884
1636 credits Members referred : 4
« Reply #2 on: Sep 13, 2006, 12:55:24 AM »
ok so how would I get all the values for player_id's from the table and then load all of those into the array, first of all ? and i have no experience with foreach
Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6357
38966 credits Members referred : 374
It's time to use PHP5!
« Reply #5 on: Sep 13, 2006, 07:01:54 AM »
from the manual:
Quote
This simply gives an easy way to iterate over arrays. foreach works only on arrays, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variable.
echo "<center><br><br>Click [<a href='".BASEDIR."administration/hiscores/index.php".$aidlink."'>here</a>] to return to the ".$module_name."</center>"; closetable(); } ?>
Quote
Warning: Invalid argument supplied for foreach() in /hsphere/local/home/meth0d42/3rd-evolution.net/administration/hiscores/commands.php on line 94
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 884
1636 credits Members referred : 4
« Reply #12 on: Sep 13, 2006, 04:51:14 PM »
for some reason this is taking the first player id result and updating its values (say it was player id 2 was the first result, it took his data and applied it to every result.. instead of loading each result then updating it with its correct data)
echo "<center><br><br>Click [<a href='".BASEDIR."administration/hiscores/index.php".$aidlink."'>here</a>] to return to the ".$module_name."</center>"; closetable(); }
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 884
1636 credits Members referred : 4
« Reply #14 on: Sep 13, 2006, 04:57:28 PM »
i tried that before, but it was giving me the same result it is giving me now, its finding (for some odd reason) the last player to register an account on the site itself when we arent even using that table, we are using a different player table