Someone could help me out?

07/12/2011 03:27 darkmanx1986#1
Hello all.I got some problems with this query
PHP Code:
<?php 

$sql_server 
"localhost";
$sql_user "user"
$sql_pass "pass"
$sql_data "PS_GameData"
$conn=mssql_connect($sql_server,$sql_user,$sql_pass);
$xadb mssql_select_db($sql_data,$conn); 
  
echo 
"<center><br><br>"
echo 
"<table border='1'> 
    <tr> 
        <td align='center'>Character Name</td> 
        <td align='center'>Level</td> 
        <td align='center'>Map</td> 
        <td align='center'>Rank</td> 

    </tr>"


$name1 mssql_query("select [CharName],[Level],[Map],[k1] from [dbo].[Chars] where LoginStatus = 1"); 
$row1 mssql_fetch_row($name1);
echo 
"<tr> 

            <td align='left'>"
.$row1[0]."</td> 
            <td align='center'>"
.$row1[1]."</td> 
            <td align='center'>"
.$row1[2]."</td> 
            <td align='center'>"
.$row1[3]."</td>     

        </tr>"


mssql_close($conn);
?>
It showing only 1 player when there are more online.Any tips on how to fix it to show all players online will be much appreciated!
07/12/2011 06:31 RebeccaBlack#2
PHP Code:
<?php 
$sql_server 
"localhost";
$sql_user "user"
$sql_pass "pass"
$sql_data "PS_GameData"
$conn=mssql_connect($sql_server,$sql_user,$sql_pass);
mssql_select_db($sql_data,$conn);

$query mssql_query("select * from [Chars] where LoginStatus = 1"); 
if(
mssql_num_rows($query)){
echo 
"<center><br><br>"
echo 
"<table border='1'> 
    <tr> 
        <th align='center'>Character Name</th> 
        <th align='center'>Level</th> 
        <th align='center'>Map</th> 
        <th align='center'>Rank</th> 

    </tr>"

while(
$row mssql_fetch_array($query)){
echo 
"<tr>";
echo 
"<td align='left'>".$row1['CharName']."</td>";
echo 
"<td align='center'>".$row1['Level']."</td>";
echo 
"<td align='center'>".$row1['Map']."</td>";
echo 
"<td align='center'>".$row1['K1']."</td>";    
echo 
"</tr>"
}
echo 
"</center></table>";
}else{echo 
"No one is online at this moment!";}
mssql_close($conn);
?>
Didn't test it, just rewrote it in a quote back to you. Am not really a PHP expert but it should work fine, you just needed a while loop on the mssql_fetch_array, so it'd pull back more data than 1 person.

*Edit* Rewrote it again, noticed unclosed tags, and I reordered the operations. ;)