PDA

View Full Version : Mysql query



Swinkid
29-02-2008, 05:20 PM
Ive got The habbo soft free user system and i want to edit all tables at once to add mass credits. (or even a mass creds php script. although i could make one if i knew the query)
Also how can i change it so when they sign up they get 100 free creds?

sgraham
29-02-2008, 05:39 PM
On the register page, once the data the user imputed is entered in to the database, update the credits column where the row is equal to the username they registered with.

Good luck.

RYANNNNN
29-02-2008, 07:00 PM
UPDATE `table` SET `credits` = '100' [WHERE `id` = '1']

[] = optional, that just sets it for people you want to set it, but the first bit will update all credits in the table.

MrCraig
29-02-2008, 11:17 PM
change the default value of the credits col in the usr_users database to 100 and theyll auto get 100 when they register.

As for giving everyone 100
Try the following php script



<?php
require("config.php");
$g1 = mysql_query("select * from usr_users");
while($cr = mysql_fetch_array($g1))
{
$newbal = $cr[credits] + 100;
mysql_query("update usr_users set credits = '$newbal' where id = '$cr[id]'");
}
echo("100 Credits have been added to all users.");
?>

RYANNNNN
01-03-2008, 03:31 PM
Whats the point in the while statement and the $g1 line?

MrCraig
01-03-2008, 04:53 PM
$g1 gets the info from db
the while adds 100 creds to every user in the database and updates individually.

RYANNNNN
01-03-2008, 11:54 PM
I'd do:
update `usr_users` set `credits` = `credits` + 100

Not sure if that will work, but you can do something alone them lines, saves having to get all the info form the db.

Want to hide these adverts? Register an account for free!