Jump to content
MakeWebGames

gangcentral update (need some help tho)


Nicholas

Recommended Posts

ok everyone, im creating a newish gang central page kinda like some userlists but im experiencing some problems

it works in ASC but it dont in DESC and i cant figure out why...

can someone help please? also if you can... could you update it little more so it works with the Members section?

as i cant figire it out... it doesnt work correctly.

here is the code (gangcentral.php)

<?php
include_once(DIRNAME(__FILE__) .'/globals.php');
$sort = (isset($_GET['sort']) && is_numeric($_GET['sort'])) ? abs(@intval($_GET['sort'])) : 'ASC';
$orderby = (isset($_GET['orderby']) && ctype_alpha($_GET['orderby'])) ? strip_tags(mysql_real_escape_string($_GET['orderby'])) : 'gangID';
echo "<h3>Gangs</h3>";
echo "

[url='?by=".$orderby."&sort=ASC']Ascending[/url]| [url='?by=".$orderby."&sort=DESC']Descending[/url]";
$gang = $db->query(sprintf("SELECT g.*,u.* FROM gangs g LEFT JOIN users u ON g.gangPRESIDENT=u.userid ORDER BY %s %s LIMIT 1000", $orderby, $sort));
$cnt= $db->query(sprintf("SELECT g.*,u.* FROM gangs g LEFT JOIN users u ON g.gangID=u.username ORDER BY %s %s LIMIT 1000", $orderby, $sort));
$sort = "".$sort;
echo "<table cellspacing=0 border=1 cellpadding=3 class=table width=95%>
<tr>
<th class=h align=center>[url='?orderby=gangID&sort=$sort']Gang ID[/url]</th>
<th class=h align=center>[url='?orderby=gangNAME&sort=$sort']Gang Name[/url]</th>
<th class=h align=center>Members</th>
<th class=h align=center>[url='?orderby=username&sort=$sort']Leader[/url]</th>
<th class=h align=center>[url='?orderby=gangRESPECT&sort=$sort']Gang Respect[/url]</th>
</tr>";
while($gangdata = $db->fetch_row($gang))
{
echo "<tr>
<td align=center>[{$gangdata['gangID']}]</td>
<td align=center>[url='gangs.php?action=view&ID=".abs(intval($gangdata[']{$gangdata['gangNAME']}[/url]<td align=center>";
$cnt=mysql_query("SELECT username FROM users WHERE gang=".abs(intval($gangdata['gangID']))."",$c);
print mysql_num_rows($cnt)."</td>
<td align=center><a href='viewuser.php?u=".abs(intval($gangdata['userid']))."'>".htmlentities($gangdata['username'])."</td>
<td align=center>".number_format($gangdata['gangRESPECT'])."</td>
</tr>";
}
echo "</table>";
$h->endpage();
?>
Link to comment
Share on other sites

ok i done

$sort = (isset($_GET['sort']) && ctype_alpha($_GET['sort'])) ? strip_tags(mysql_real_escape_string($_GET['sort'])) : 'ASC';

and it works now thanks. but is there any chance you could help me with the Members bit?

or do you think i have to add gangMEMBERS into gangs section and edit it to show the number of gang members in the gang

to do it with the ASC and DESC stuff?

if thats understandable?

as i tired

<th class=h align=center>[url='?orderby=$cnt&sort=$sort']Members[/url]</th>

 

but it didnt work the link i got was

?orderby=Resource id #12&sort= ASC

some reason

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...