1
JS
Help with some code please
  • 2005/1/11 8:36

  • JS

  • Just popping in

  • Posts: 87

  • Since: 2002/12/16


hey all I am working on porting into XOOPS a guild roster for WoW. But I am having some issues. First of all the database tables are all in place and there is data in them. That was the easy part now the problem that I am having is the code I am using will not display the information from the database. Maybe someone who is better with php then me can look at the code and tell me if I am really hosed or what.

<?php
// let start including the header of xoops
include("../../mainfile.php"); // including top functions of xoops
include(XOOPS_ROOT_PATH."/header.php"); // including the rest ?>
<?php 
include "conf.php"; ?>

<center>
<table width="100%">
<tr><th><a class="title" href="?sort=name">Name</a></th>
<th><a class="title" href="?sort=race">Race</a></th>
<th><a class="title" href="?sort=class">Class</a></th>
<th><a class="title" href="?sort=level">Level</a></th>
<th><a class="title" href="?sort=guild_rank">Rank</a></th>
</tr>
<?php
$link 
= mysql_connect($db_host, $db_user, $db_passwd) or die("Could not connect");
mysql_select_db($db_name) or die("Could not select DB");

$query = "SELECT * FROM `guild_char`";
if( 
$guild_name != "" ){
    
$query .= " WHERE guild_name = '$guild_name'";
}

if( 
$_REQUEST['sort'] == 'name' ) {
  
$query .= " ORDER BY name";
} else if( 
$_REQUEST['sort'] == 'race' ) {
  
$query .= " ORDER BY race";
} else if( 
$_REQUEST['sort'] == 'class' ) {
  
$query .= " ORDER BY class";
} else if( 
$_REQUEST['sort'] == 'guild_rank' ) {
  
$query .= " ORDER BY guild_rank"; 
} else {
  
$query .= " ORDER BY level DESC";
}
print 
"<!-- $query -->";

$result = mysql_query($query) or die(mysql_error());


while ( 
$row = mysql_fetch_assoc( $result ) )
{
?>
 <tr>
<td><a class="charlink" 
href="char.php?name=<?php print $row['name']; ?>&server=<?php print $row['server']; ?>">
<?php print $row["name"]; ?></a></td>
<td><?php print $row["race"]; ?></td> 
<td><?php print $row["class"]; ?></td>
<td><?php print $row["level"]; ?></td>
<td><?php print $row["guild_rank"]; ?></td>
</tr>
<?php
}

?>
</table>
</center>


<?php
// including footer of xoops
include(XOOPS_ROOT_PATH."/footer.php");
// done
?>

maybe someone can tell me where I have gone wrong.

2
wtravel
Re: Help with some code please

What does the result look like? Do you see any errors on the page or below the footer?

Usually I insert an extra code to display the number of results from a query first, so that I know that the query is correct or not.

Regards,

Martijn