Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Beginner coder, wondering about php.

Newbie Spellweaver
Joined
Feb 11, 2019
Messages
25
Reaction score
1

Hello!
I am a beginner in coding so I started to put a online colum in my ranking system of MuOnline. Having the $quey's written I am looking for someone who can help me find my error :DI will write only the colum and the lines I wrote.having the usual line $query

Code:
$query = "SELECT TOP 30 Name,Class,cLevel,RESETS,mLevel,Grand_Resets,WinDuels,MapNumber,AccountID from Character where CtlCode < '8' order by Grand_Resets desc, RESETS desc, WinDuels desc";
$rank_char = $core_db->getAll($query);
for($i=0;
$i < count($rank_char);++$i)
{
$row = $rank_char[$i];
$acc_id=$row['AccountID'];
$line = sqlsrv_query("SELECT ConnectStat FROM Me_MuOnline.dbo.MEMB_STAT where memb___id='$acc_id'")
$rank = $i+1;
if ($line['ConnectStat']) 
{0 == 'Offline';} 
else {1 == 'Online';} 
            echo' Here will be the tables html I am supposed to write but I resume to not write here';
}
So the result in my ranking is empty.

CYRT6AV - Beginner coder, wondering about php. - RaGEZONE Forums


So now, trying the other way. I get only one result from the colum.table.db. which is 0 = Offline

Code:
    $query = "SELECT TOP 30 Name,Class,cLevel,RESETS,mLevel,Grand_Resets,WinDuels,AccountID from Character where CtlCode < '8' order by Grand_Resets desc, RESETS desc, WinDuels desc";
$rank_char = $core_db->getAll($query);
for($i=0;
$i < count($rank_char);++$i)
{
$row = $rank_char[$i];
$acc_id=$row['AccountID'];
$line = sqlsrv_query("SELECT ConnectStat FROM Me_MuOnline.dbo.MEMB_STAT where memb___id='$acc_id'")
$rank = $i+1;
if($line[0] == 0)
{$line[0] = 'Offline';}
else if($line[0] == 1)
{$line[0] = 'Online';}
else{$line[0] = 'Offline';}
echo '[LEFT][COLOR=#222222]Here will be the tables html I am supposed to write but I resume to not write here' [/COLOR];
[/LEFT]
}
NGoYTK3 - Beginner coder, wondering about php. - RaGEZONE Forums


It's obvious that I use <td>'.$line[0].'</td> in the Status where it shows Online or Empty. If there are dudes of my lines ask me so I explain more detailed.
So my Idea is to show if the players are online or not, and to make it done the line have to read '1' so it can show online. It's complicated to me and as I told you I am a beginner. The lines I took by myself reading other lines from MuCore.
Info.
PHP +7.1.x
SQL 2018.
Web: MuCore version of Kevin Fernandez.
The $row[1] is already fixed to make the class work giving me each name of the race.

Thank you for your answer guys :)


 

Attachments

You must be registered for see attachments list
Last edited:
Elite Diviner
Joined
Aug 15, 2008
Messages
489
Reaction score
43
It's been a long time since I last used PHP, but perhaps something like this would work.

Code:
$query = "SELECT TOP 30 Name,Class,cLevel,RESETS,mLevel,Grand_Resets,WinDuels,MapNumber,AccountID from Character where CtlCode < '8' order by Grand_Resets desc, RESETS desc, WinDuels desc";
$rank_char = $code_db->getAll($query);
for ($i = 0; $i < count($rank_char); $i++) {
  $status = sqlsrv_query("SELECT ConnectStat FROM Me_MuOnline.dbo.MEMB_STAT where memb___id='$acc_id'");
  $rank_char[$i]["status"] = $status["ConnectStat"] ? "Online" : "Offline";
  $rank_char[$i]["rank"] = $i + 1;
}

foreach($rank_char as $character) {
  echo "<tr>";
  // Add your other echos here, such as the Name, Class, cLevel, etc...
  echo "<td>" . $character["rank"] . "</td>";
  echo "<td>" . $character["status"] . "</td>";
  echo "</tr>";
}

If this still doesn't work, feel free to add me on Discord and I can try to help you further. Wokki#0001
 
Last edited:
Newbie Spellweaver
Joined
Feb 11, 2019
Messages
25
Reaction score
1
Don't you have to rename the result of the colum? like 0 or 1 to offline and online? I am anyways trying.

As example here, online and offline are a result of the colum ConnectStat.

$rank_char[$i]["status"] = $status["ConnectStat"] ? "Online" : "Offline";

 
Elite Diviner
Joined
Aug 15, 2008
Messages
489
Reaction score
43
What is being done is , which is essentially an if else to check if value is true or false.

In the example
Code:
$rank_char[$i]["status"] = $status["ConnectStat"] ? "Online" : "Offline";
the variable $rank_char[$i]["status"] is given value "Online" if $status["ConnectStat"] is true, and "Offline" if it is false.

EDIT: Also it appears your sqlsrv_query is wrong.
 
Last edited:
Newbie Spellweaver
Joined
Feb 11, 2019
Messages
25
Reaction score
1
Thank you very much man! for having time to help and see the solution :D

F3dYfnK - Beginner coder, wondering about php. - RaGEZONE Forums
 

Attachments

You must be registered for see attachments list
Back
Top