• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

SQL help

Xerez

New Member
Joined
Mar 6, 2008
Messages
45
Reaction score
0
Hi, if I want to run a "question" in sql it says as default:

SELECT * FROM `players`

but I want it to something like this: take players cap and add 1000cap to it, to all players. Is it possible to make a code like that?

GETCAP + 1000 ? :D:D:D

I dont know anything about this stuff, but is it possible? please help me!
 
You must run it only one time?

You can do it with php:

PHP:
<?php
$i = 0;
$query = mysql_query("SELECT id, cap FROM players");

while ($data = mysql_fetch_array($query)) {
        $id = $data['id'];
        $cap = $data['cap'] + 1000;
        mysql_query("UPDATE players SET cap = '".$cap."' WHERE id = '".$id."'");
        $i++;
}

echo "$i players updated!";
?>
 
You must run it only one time?

You can do it with php:

PHP:
<?php
$i = 0;
$query = mysql_query("SELECT id, cap FROM players");

while ($data = mysql_fetch_array($query)) {
        $id = $data['id'];
        $cap = $data['cap'] + 1000;
        mysql_query("UPDATE players SET cap = '".$cap."' WHERE id = '".$id."'");
        $i++;
}

echo "$i players updated!";
?>

Why bother doing it in PHP when you could execute a query directly? You're just complicating things that way :o
 
Back
Top