Me again :o
I've been trying to figure this out for about 20hrs now and I finally give up and will have to ask (sorry).
ugh, where to begin...
Ok first, please take a look at the 2 drop down select menus on my page. The one on the right (squads) is a default one and the one on the left is my own, modelled on the default one. If you select a squad from the right menu, it will filter out and display only the results for the selected squad, but if you select an opponent (try Clan Bankai) in my menu, it will show no entries - even though there are 2 results vs Clan Bankai to be displayed (as you can see if you select 'show all opponents' and click 'go').
The way the results are filtered to be displayed for a specific squad appears to be by first checking with a 'squads' db table and retrieving all gaming squads and their unique ID #. It then adds these squads to the menu and pulls the results from the 'clanwars' db for entries pertaining to that squad ID:
if($action=="showonly") {
$only = 'squad';
if(isset($_GET['only'])){
if($_GET['only']=="squad") $only = $_GET['only'];
}
$squads=getgamesquads();
$jumpsquads=str_replace('value="', 'value="index.php?site=clanwars&action=showonly&only=squad&id=', $squads);
$jumpmenu='<select name="selectgame" onchange="MM_jumpMenu(\'parent\',this,0)"> <option value="index.php?site=clanwars">- '.$_language->module['show_all_squads'].' -</option>'.$jumpsquads.'</select> <input type="button" name="Button1" value="'.$_language->module['go'].'" onclick="MM_jumpMenuGo(\'selectgame\',\'parent\',0)" class="button" onfocus="blur()" />';
The function 'getgamesquads' is:
function getgamesquads() {
$squads = '';
$ergebnis=safe_query("SELECT * FROM ".PREFIX."squads WHERE gamesquad='1'");
while($ds=mysql_fetch_array($ergebnis)) {
$squads.='<option value="'.$ds['squadID'].'">'.$ds['name'].'</option>';
}
return $squads;
}
The way I've worked mine is by giving each opponent a unique ID (actually each opponent is assigned a unique ID when they're added through admin cp). The opponent data is stored within a db table called 'opponents' and the drop down menu retrieves the list of opponents from that table. I then added a field to the clanwars db table (where the results are stored) and have things set so that when a result is posted, the relevant opponent ID is retrieved from the opponents table and is stored within the clanwars table, along with all the other information (squad, scores etc).
heres how the opponent db table looks (note the oppID number for 'clan bankai' = 130).
And heres how the clanwars db table looks (note the same oppID for 'clan bankai').
I then hoped to be able to pull from the clanwars (results) table, all results associated with an opponent ID when selected in the drop down menu, but for some reason it isn't having none of it - because I think I've made an error in the code.
elseif($action=="opponent") {
if(isset($_GET['id'])){
if(is_numeric($_GET['id']) || (is_gametag($_GET['id']))) $id = $_GET['id'];
}
// this is getting the game tag, for example 'Modern Warfare 2' = mw2
// is_gametag function =
// function is_gametag($tag){
// $anz = mysql_num_rows(safe_query("SELECT name FROM `".PREFIX."games` WHERE tag='$tag'"));
// return $anz;
//}
if(isset($_GET['cwID'])) $cwID = (int)$_GET['cwID'];
// cwID = Clan War ID, a unique number assigned to each and every clan war result when posted within the db
$only = 'opponent';
if(isset($_GET['only'])){
if($_GET['only']=="opponent") $only = $_GET['only'];
}
if(isset($_GET['page'])) $page=(int)$_GET['page'];
else $page = 1;
$sort="date";
// defines sortable table column headers
if(isset($_GET['sort'])){
if(($_GET['sort']=='date') || ($_GET['sort']=='game') || ($_GET['sort']=='squad') || ($_GET['sort']=='opponent') || ($_GET['sort']=='oppcountry') || ($_GET['sort']=='league')) $sort=$_GET['sort'];
}
// defines default sort type
$type="DESC";
if(isset($_GET['type'])){
if(($_GET['type']=='ASC') || ($_GET['type']=='DESC')) $type=$_GET['type'];
}
// original jumpmenu for showing only squads which mine is based on:
$squads=getgamesquads();
$jumpsquads=str_replace('value="', 'value="index.php?site=clanwars&action=showonly&only=squad&id=', $squads);
$jumpmenu='<select name="selectgame" onchange="MM_jumpMenu(\'parent\',this,0)"> <option value="index.php?site=clanwars">- '.$_language->module['show_all_squads'].' -</option>'.$jumpsquads.'</select> <input type="button" name="Button1" value="'.$_language->module['go'].'" onclick="MM_jumpMenuGo(\'selectgame\',\'parent\',0)" class="button" onfocus="blur()" />';
// getgamesquads function =
// function getgamesquads() {
// $squads = '';
// $ergebnis=safe_query("SELECT * FROM ".PREFIX."squads WHERE gamesquad='1'");
// while($ds=mysql_fetch_array($ergebnis)) {
// $squads.='<option value="'.$ds['squadID'].'">'.$ds['name'].'</option>';
// }
// return $squads;
// }
// my jump menu
$opponents=getopponents();
$jumpopponents=str_replace('value="', 'value="index.php?site=clanwars&action=opponent&only=opponent&id=', $opponents);
$jumpmenuopp='<select name="selectopponent" onchange="MM_jumpMenu(\'parent\',this,0)"> <option value="index.php?site=clanwars">- show all opponents -</option>'.$jumpopponents.'</select> <input type="button" name="Button1" value="'.$_language->module['go'].'" onclick="MM_jumpMenuGo(\'selectopponent\',\'parent\',0)" class="button" onfocus="blur()" />';
// end
// my getopponents function =
// function getopponents() {
// $opponents = '';
// $ergebnis=safe_query("SELECT * FROM ".PREFIX."opponents ORDER BY clanname" );
// while($ds=mysql_fetch_array($ergebnis)) {
// $opponents.='<option value="'.$ds['oppID'].'">'.$ds['clanname'].'</option>';
// }
// return $opponents;
//}
echo '<div id="tabs">
<ul>
<li class="activetab"><a href="index.php?site=clanwars"><span>Results</span></a></li>
<li><a href="index.php?site=clanwars&action=stats"><span>Stats</span></a></li>
</ul>
</div>
<div class="webspell-head"></div>';
// select clan war result from clanwars db where $only (opponent) = $id (game tag)
$gesamt = mysql_num_rows(safe_query("SELECT cwID FROM ".PREFIX."clanwars WHERE $only='$id'"));
// ---------- Dont think problem is below here so end it there -----------
Would someone please mind checking to see if I'm missing something or have things set correctly?
Really appreciate it.
(sorry for long post)