All three of these read like good answers, but in practice, I'm struggling to get any to work. Thank you for your quick responses, I've gone with Phycho's answer as it reads like the most familiar to what I'm used too at the moment, but I am getting a sytax error ' [1/1] Syntax error, unexpected '{' on Line 15 ' this is the '{' just after the do command.
$generateRecords = isset($argv[1])?intval($argv[1]):0;
$db = new PDO('mysql:host=localhost;dbname=databasename,user,password');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
/Update team values to random number
$sql = "UPDATE players SET team = RAND()";
$mysqli->query($sql);
//Create var to hold team number
$teamNo = 0;
do
{
//Increment team number
$teamNo++;
$sql = "UPDATE players
SET team = {$teamNo}
WHERE team < 1
ORDER BY team
LIMIT 5";
$mysqli->query($sql);
//Continue loop as long as there were rows updated
} while($mysqli->affected_rows);
The only thing I've changed is the table name, user and pass to my own, but having always done mysql_connect / mysql_queary functions, I'm having a little trouble getting used to the new PDO style. I'm happy my table is good for all examples, I've altered my existing table to match the one suggest by Kicken.
To give you an idea of what I do, I c+p from your suggestions to a php file, make the alterations to table name etc then go to this file in my browser and refresh it. I get, as you imagine, a blank page, but nothing changes in the table. I've cleared the cache and tried on a couple of comps in case it was storing the old setting for some reason. Sorry if I am coming across as a super noob, but i've tried for a good 1/2 day with these solutions and can't crack what the issues are.
Any further help much appreciated.
Thanks,
Toastie