I've already made a question about this here. But since i didn't get answer that helped me a lot i would like to ask again.
In Database [1]
Table Characters
+----+------------------+-------+---------+
|account_name| lastaccess| online| voted |
+------------+-----------+-------+--------+
| Account1 | 1231321231| 1 | 1 |
| Account1 | 132312213 | 0 | 0 |
| Account3 | 13231212 | 0 | 0 |
+------------+-----------+-------+--------+
In Database [2]
Table Accounts
+----+------------------+
| Login | lastIp |
+-----------+-----------+
| Account1 | 0.0.0.0.0 |
| Account1 | 0.0.0.0.0 |
| Account3 | 0.0.0.0.0 |
+-----------+-----------+
I've already got a function that gets where lastIP account.
function getclientip()
{
if ( isset($_SERVER["REMOTE_ADDR"]) ) {
return $_SERVER["REMOTE_ADDR"];
} else if ( isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ) {
return $_SERVER["HTTP_X_FORWARDED_FOR"] ;
} else if ( isset($_SERVER["HTTP_CLIENT_IP"]) ) {
return $_SERVER["HTTP_CLIENT_IP"] ;
}
return "0.0.0.0";
}
$Ip=getclientip();
$sql='SELECT login FROM accounts WHERE lastIp like \''.$Ip.'\';';
echo mysql_error();
$result = mysql_query($sql);
if (false === $result) {
}
while($row = mysql_fetch_array($result))
{
What I want do is:
mysql_query('update characters SET voted=1 where account_name like \''.$row['login'].'\' and online=1;') ;
But where MIN(lastaccess)
only.
I hope you get my mind, in other case ask me i will explain better.