Hi There,
I got some code from another site regarding sort-able tables and I am trying to adapt it to for my use.
Here is the code I got from the site.
[php]<?php
require_once ( ‘mysql_connect.php’ );
?>
Untitled Document <?phpif ( isset ( $_GET[‘order_var’] ) )
{
$order_var = $_GET[‘order_var’];
switch ( $order_var )
{
case 'fn_asc':
$order_var = "FullName ASC";
break;
case 'fn_dsc':
$order_var = "FullName DESC";
break;
case 'ln_asc':
$order_var = "GP ASC";
break;
case 'ln_dsc':
$order_var = "GP DESC";
break;
case 'id_asc':
$order_var = "Goals ASC";
break;
case 'id_dsc':
$order_var = "Goals DESC";
break;
}
}
else
{
$order_var = “FullName ASC”;
}
$query = “SELECT * FROM SeasonStats ORDER BY $order_var”;
print $query;
$result = mysql_query ( $query );
$id_var = “FN_asc”;
$fn_var = “GP_asc”;
$ln_var = “Goals_asc”;
if ( $order_var == “FullName ASC” )
{
$id_var = “FN_dsc”;
}
else if ( $order_var == “FullName DESC” )
{
$id_var = “FN_asc”;
}
if ( $order_var == “GP ASC” )
{
$fn_var = “GP_dsc”;
}
else if ( $order_var == “FullName DESC” )
{
$fn_var = “FN_asc”;
}
if ( $order_var == “Goals ASC” )
{
$ln_var = “Goals_dsc”;
}
else if ( $order_var == “Goals DESC” )
{
$ln_var = “Goals_asc”;
}
print ’
Player Name | GP | Goals |
' . $row['FullName'] . ' | ' . $row['GP'] . ' | ' . $row['Goals'] . ' |
?>
© Asib12 2009
I have been able to figure out how to change the variables and what not but on my site it calls for a Where statement with two variables and I cannot figure out where to put them to get the table to work.
Here is the code I want to transform from my site.
[php]<?php
// Connects to your Database
mysql_connect("", “cnghldb”, “”) or die(mysql_error());
mysql_select_db("") or die(mysql_error());
//Get TeamID from URL
$iTeamID = $_GET[“TeamID”];
$iPlayerID= $_GET[“PlayerID”];
$iSea=$_GET[“Sea”];
Print “<img src=“http://www.cnghl.org/cnghldb/cnghlimages/".$iTeamID.".png”>”;
$oteaminfo = mysql_query("
SELECT Players.FullName, Seasonteam.TeamID, SeasonStats.Sea, SeasonStats.GP, SeasonStats.Goals, SeasonStats.Assists, SeasonStats.Points, SeasonStats.Pim, SeasonStats.PlusMinus, SeasonStats.PP, SeasonStats.SH, SeasonStats.GW, SeasonStats.GT, SeasonStats.S, Players.PlayerID
FROM Seasonteam
LEFT JOIN (Players
LEFT JOIN SeasonStats ON Players.PlayerID = SeasonStats.PlayerID)
ON Seasonteam.TeamID = SeasonStats.TeamID
WHERE Seasonteam.TeamID=$iTeamID AND SeasonStats.Sea=$iSea
ORDER BY SeasonStats.Points DESC;
") or die(mysql_error());
Print “
Player Name | ”;GP | ”;G | ”;A | ”;PTS | ”;PIM | ”;+/- | ”;PP | ”;SH | ”;GW | ”;GT | ”;S | ”;
’ . $row[‘FullName’] . ‘ | ’;”.$row[‘GP’]." | “;”.$row[‘Goals’].” | “;”.$row[‘Assists’].” | “;”.$row[‘Points’].” | “;”.$row[‘Pim’].” | “;”.$row[‘PlusMinus’].” | “;”.$row[‘PP’].” | “;”.$row[‘SH’].” | “;”.$row[‘GW’].” | “;”.$row[‘GT’].” | “;”.$row[‘S’].” | ";