I have a page in PHP which displays a SQL query output into an HTML table. What I need to accomplish is making the table sort-able by clicking on the headers (i.e. one click sorts acesnding, second click sorts decending..etc.)
I am new to PHP and have been told that possibly the best way would be to write a multi dimensional array.
Here is an example of the query and table section of my code...again I am new to PHP so excuse any "mistakes":
<div id="centercontent">
<TABLE border="1" width="800" height="0" bordercolorlight="#fff" align="left"
bordercolordark="#black" bordercolor="#006666">
<TH width="110"><span title="Date of Occurence">Date</br>dd/mm/
yyyy</span
></TH>
<TH width="70"><span title="Location Number">Location</span></T
H>
<TH width="70"><span title="Sum of CRC+Frame+Abort+Giants+Run
ts @ Remote">Physical Errors</span></TH>
<TH width="70"><span title="BECNs Received by Remote">Remote BECNs</span></TH>
<TH width="80"><span title="Frame Delivery Rate to the Head End">FDR-HE</span></TH>
<TH width="80"><span title="Frame Delivery Rate to the Remote End">FDR-RE</span></TH>
<TH width="40"><span title="Frame Delivery Rate Objective">FDR</span></TH>
<TH width="80"><span title="Data Delivery Rate to the Head End">DDR-HE</span></TH>
<TH width="80"><span title="Data Delivery Rate to the Remote End">DDR-RE</span></TH>
<TH width="40"><span title="Data Delivery Rate Objective">DDR</span></TH>
<TH width="80"><span title="Daily Score=Frame Delivery Rate Objective+Data Delivery Rate Objective/2">Daily Score</span></TH></TABLE>
</div>
<br />
<br />
<br />
<?
if (!(isset($day)))
{
$day = 1;
}
$db = &new MSSQL($dbi['host'], $dbi['user'], $dbi['pass'], $dbi['database']);
$FDRHE='[FDRtoHE]';
$FDRRE='[FDRtoRE]';
$DDRHE='[DDRtoHE]';
$DDRRE='[DDRtoRE]';
$DDR='[DDRtoHE]+[DDRtoRE]'
;
$FDR='[DDRtoHE]+[DDRtoRE]'
;
$sql = "Select
mm,dd,yyyy,Location,
AVG(RmtPri+PriSec) AS SysTimeDelta,
PhysicalErrors,BECNsFromRe
mote,
FDRtoHE, FDRtoRE, DDRtoHE, DDRtoRE,
Round((((SUM($FDRHE+$FDRRE
)/2))/Coun
t (*)),2) AS FDR,
Round((((SUM($DDRHE+$DDRRE
)/2))/Coun
t (*)),2) AS DDR,
Round((((SUM($DDR+$FDR)/2)
)/2),2)AS DailyScore
From ##mytemptable
Group By mm,dd,yyyy,Location,Physic
alErrors,B
ECNsFromRe
mote,RmtPr
i,PriSec,F
DRtoHE, FDRtoRE, DDRtoHE, DDRtoRE
Order By mm,dd,yyyy,DailyScore,Loca
tion;";
$result = $db->query($sql);
?>
<div id="centercontent" style=" width:820px; height:500px; overflow:auto;">
<?
echo "<TABLE style='text-decoration:non
e' border='1' width='800' height='0' bordercolorlight='#fff' align='left'
bordercolordark='#black' bordercolor='#006666' >";
while ($row = $result->fetch())
{
echo "<TR>";
echo "<TD width='25'align='center'>"
. $row['dd'] . "</TD>";
echo "<TD width='25'align='center'>"
. $row['mm'] . "</TD>";
echo "<TD width='25'align='center'>"
. $row['yyyy'] . "</TD>";
echo "<TD width='80'align='center'>"
. $row['Location'] . "</TD>";
echo "<TD width='80'align='center'>"
. $row['PhysicalErrors'] . "</TD>";
echo "<TD width='80'align='center'>"
. $row['BECNsFromRemote'] . "</TD>";
echo "<TD width='80'align='center'>"
. $row['FDRtoHE'] . "</TD>";
echo "<TD width='80'align='center'>"
. $row['FDRtoRE'] . "</TD>";
echo "<TD width='42'align='center'>"
. $row['FDR'] . "</TD>";
echo "<TD width='80'align='center'>"
. $row['DDRtoHE'] . "</TD>";
echo "<TD width='80'align='center'>"
. $row['DDRtoRE'] . "</TD>";
echo "<TD width='40'align='center'>"
. $row['DDR'] . "</TD>";
echo "<TD width='80'align='center'>"
. $row['DailyScore'] . "</TD>";
echo "</TR>";
}
echo "</TABLE>";
?>
</div>
</body>
</HTML>