PDA

View Full Version : PHP


Domzelan
15.04.2005, 08:22
This script shows us online status, pladge_id - is number how i can take "name" for pledge_id from Pladge table?

<?
include("config.php");

mssql_connect($mssql_server,$mssql_user,$mssql_pas s);
mssql_select_db($mssql_db);

$result=mssql_query("
select
char_name, pledge_id, builder,
class, use_time,
PK, Duel, align
from user_data
where login>logout AND LOGOUT>0 AND LOGIN>0 AND account_id>=1
order by char_name
");
$online_users=array();
for($x=0;$online_users[$x]=mssql_fetch_assoc($result);$x++){
$online_users[$x]['use_time_h']=round($online_users[$x]['use_time']/3600,1)."h";
};
unset($online_users[count($online_users)-1]);

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<META HTTP-EQUIV="Expires" CONTENT="Fri, Jan 01 1900 00:00:00 GMT">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META http-equiv="Content-Type" content="text/html; charset=windows-1251">
<META http-equiv="content-language" content="en">
<META name="author" content="">
<META HTTP-EQUIV="Reply-to" CONTENT="@.com">
<META name="generator" content="PHPEd 3.1">
<META NAME="description" CONTENT="">
<META name="keywords" content="">
<META NAME="Creation_Date" CONTENT="08/15/2000">
<META name="revisit-after" content="15 days">
<title>Online</title>
</head>
<body>
<table border="1" align=center size=5>
<tr>
<td colspan="5">LineAgeII Server Online:</td>
</tr>
<tr>
<td>Nick</td>
<td>Clan</td>
<td>Class</td>
<td>Total in game</td>
<td>PvP/PK</td>
</tr>
<?for($x=0;$x<count($online_users);$x++)
{?>
<tr>
<td style="color:<?=$online_users[$x]["align"]?"#FF8080":"#8080FF"?>"><?=$online_users[$x]["char_name"]?>
</td>
<td><?=$online_users[$x]["pledge_id"]?></td>
<td><?=$class_list[$online_users[$x]["class"]]?></td>
<td><?=$online_users[$x]["use_time_h"]?></td>
<td><?=$online_users[$x]["Duel"]?>/<?=$online_users[$x]["PK"]?></td>
</tr>
<?}?>
<tr>
<td colspan="3">Total Online:</td>
<td><?=count($online_users)?></td>
</tr>
</table>
</body>
</html>

Sakumi
15.04.2005, 08:23
Oh excelent, thank you!!!

what about config.php?

Domzelan
15.04.2005, 10:20
This script shows us online status, pladge_id - is number how i can take "name" for pledge_id from Pladge table?
If somebody help me I'll post config.php

Domzelan
15.04.2005, 10:22
Sakumi - ragezone it is you?

Riane
15.04.2005, 12:38
i guess pledge id is the a number, then search for the clan with that number in the pledge table and ure done having the name, that wasnt much brainpower was it

Domzelan
15.04.2005, 13:17
I mean, make a php status, script take pladge_id and go Pladge table - take there name and put it in status...

Osito2Dancer
15.04.2005, 17:53
Instead of this: select char_name, pledge_id, builder, class, use_time, PK, Duel, align from user_data where login>logout AND LOGOUT>0 AND LOGIN>0 AND account_id>=1 order by char_name

do this one:

select user_data.char_name, pledge.pledge_name, user_data.class, user_data.PK, user_data.Duel, user_data.align from user_data, pledge where login>logout AND LOGOUT>0 AND LOGIN>0 AND builder=0 and pledge.pledge_id = user_data.pledge_id order by char_name desc

This way, itll show Char Name, Pledge Name, Class, How many times he has been PK, how many Duels he has fought and Karma at the moment. It'll show only Players (Builder = 0) and it'll show the clan name. Nice select, you should try it in the query analyzer and fix the wrong naming (For instance, im not sure hat pledge is a table inside lin2world, or if the name is called by pledge_name). If you want a top X, just put "select top X" at the beginning and "order by lev desc".

Hope it helps, im here all week for any questions xD

Oso

Riane
15.04.2005, 20:26
select top X
that works? im always working with limits,
order by lev desc limit X

Osito2Dancer
15.04.2005, 21:01
at least in my query, it works.

Top 50 Top 10 Top 1000... they all work!

Oso

Riane
15.04.2005, 21:40
this script is kinda complicated, it could be done very much easier..
well either way, put in config.php
<?
$mssql_server="serverhost/ip";
$mssql_user="SQL user";
$mssql_pass="SQL password";
$mssql_db="lin2world"; //if im not mistaken, put database with player data in here^^
?>


that should make it work

Domzelan
16.04.2005, 09:52
no no no - this is online status, pledge.pledge_id = user_data.pledge_id - shows only players who have CLAN but i need to show who online and his clan name, if hi dont own clan - shows Blank.

Osito2Dancer
16.04.2005, 16:28
no no no - this is online status, pledge.pledge_id = user_data.pledge_id - shows only players who have CLAN but i need to show who online and his clan name, if hi dont own clan - shows Blank.
Humm... if you dont put that condition, it'll show a cross-point of results... SQL does that very often xD.

I think Pledge_id = 0 shows blank. do a select to a var in php with the values of pledge_id, and do an if:

varsql = "select pledge_id from pledge"
if (varsql = 0) show "No Clan"

Hope it helps

Oso

Domzelan
17.04.2005, 12:09
plz post fuff varisnt here :) - my edited script - PLEEEZ :)

Riane
17.04.2005, 12:15
please try again o.O

Domzelan
17.04.2005, 12:19
I'll try again and again and i cant :( Riane plz help me...

Riane
17.04.2005, 12:33
<td><?=$online_users[$x]["pledge_id"]?></td>

replace with this

<td>
<?
$clanquery=mssql_query("SELECT pledge_name FROM pledge WHERE pledge_id = '".$online_users[$x]["pledge_id"]."'");
if(!mssql_num_rows($clanquery))
echo"No Clan";
else {
$clan=mssql_fetch_array($clanquery);
echo $clan[pledge_name];
}
?></td>

Domzelan
17.04.2005, 16:31
OOOOOOOOOOO EEEEEEEEEEEEEEEEE :)))))))))) THX A LOT
rewrite some... working....

and last - how i can did - if clan have level 3 ore 4 ore 5 - then this clan name shows and if clan level <3 shows No Clan ?:))))

Domzelan
17.04.2005, 16:35
I'll do it my self thx :)