Hello :o
Quicker to show you...
http://www.clanrv.worldclanleague.com/index.php?site=timetrials_lc&sort=nickname&page=1
If you click on 'nickname' (or any other value) it doesn't sort straight away but instead appears to just set the sort type. Then when you click 'sort', it'll sort the table.
What I would like instead is for it to sort straight away when you click on nickname, and sort again the opposite direction when it's clicked again (the traditional way):
Example:
http://www.ajaxdaddy.com/demo-table-sort.html
(but thats Java)
I'm using this code:
php
$sort="LC";
if(isset($_GET['sort'])){
if(($_GET['sort']=='nickname') || ($_GET['sort']=='clantag') || ($_GET['sort']=='LC')) $sort=$_GET['sort'];
}
$type="ASC";
if(isset($_GET['type'])){
if(($_GET['type']=='ASC') || ($_GET['type']=='DESC')) $type=$_GET['type'];
}
if($pages>1) $page_link = makepagelink("index.php?site=timetrials_lc&sort=$sort&type=$type", $page, $pages);
else $page_link='';
if($page == "1") {
$ergebnis = safe_query("SELECT * FROM ".PREFIX."timetrials ORDER BY ".$sort." ".$type." LIMIT 0,".$maxusers);
if($type=="DESC") $n=$gesamt;
else $n=1;
}
else {
$start=$page*$maxusers-$maxusers;
$ergebnis = safe_query("SELECT * FROM ".PREFIX."timetrials ORDER BY ".$sort." ".$type." LIMIT ".$start.",".$maxusers);
if($type=="DESC") $n = ($gesamt)-$page*$maxusers+$maxusers;
else $n = ($gesamt+1)-$page*$maxusers+$maxusers;
}
$jumpmenu='<select name="select_member_type" onchange="MM_jumpMenu(\'parent\',this,0)">
<option value="index.php?site=timetrials_lc">- Show all users -</option>
<option value="index.php?site=timetrials_lc_rv">- Show only Rv members -</option>
</select>
<input type="button" name="Button1" value="go" onclick="MM_jumpMenuGo(\'select_member_type\',\'parent\',0)" class="button" onfocus="blur()" />';
$anz=mysql_num_rows($ergebnis);
if($anz) {
if($type=="ASC")
$sorter = '<a href="index.php?site=timetrials_lc&page='.$page.'&sort='.$sort.'&type=DESC"><img src="images/icons/sort_asc.gif" width="49" height="18" border="0" style="vertical-align:middle;" alt="Sort DESC" /></a>';
else
$sorter = '<a href="index.php?site=timetrials_lc&page='.$page.'&sort='.$sort.'&type=ASC"><img src="images/icons/sort_desc.gif" width="49" height="18" border="0" style="vertical-align:middle;" alt="Sort ASC" /></a>';
html
<td class="timetrials-table-title" width="10%" style="color:#dbdbdb;"><a href="index.php?site=timetrials_lc&sort=LC&page=$page">#</a></td>
<td class="timetrials-table-title" width="40%" style="color:#dbdbdb;"><a href="index.php?site=timetrials_lc&sort=nickname&page=$page">Nickname</a></td>
<td class="timetrials-table-title" width="20%" style="color:#dbdbdb;"><a href="index.php?site=timetrials_lc&sort=clantag&page=$page">Clan</a></td>
<td class="timetrials-table-title" width="30%" style="color:#dbdbdb;"><a href="index.php?site=timetrials_lc&sort=LC&page=$page">Time</a></td>
Thanks in advance.