Advertisement

01.31.2005 at 06:23AM PST, ID: 21295264
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.9

PHP and SQL- Sorting data in a table dynamically

Asked by kcmoore in PHP and Databases

Tags: , , ,

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></TH>
            <TH width="70"><span title="Sum of CRC+Frame+Abort+Giants+Runts @ 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,BECNsFromRemote,
      FDRtoHE, FDRtoRE, DDRtoHE, DDRtoRE,
      Round((((SUM($FDRHE+$FDRRE)/2))/Count (*)),2) AS FDR,  
      Round((((SUM($DDRHE+$DDRRE)/2))/Count (*)),2) AS DDR,
      Round((((SUM($DDR+$FDR)/2))/2),2)AS DailyScore       
From ##mytemptable
Group By mm,dd,yyyy,Location,PhysicalErrors,BECNsFromRemote,RmtPri,PriSec,FDRtoHE, FDRtoRE, DDRtoHE, DDRtoRE
Order By mm,dd,yyyy,DailyScore,Location;";

$result = $db->query($sql);

 ?>
 <div id="centercontent" style=" width:820px; height:500px; overflow:auto;">
 <?
      
 echo "<TABLE style='text-decoration:none' 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>Start Free Trial
[+][-]01.31.2005 at 07:56AM PST, ID: 13183668

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PHP and Databases
Tags: php, sort, table, sql
Sign Up Now!
Solution Provided By: ldbkutty
Participating Experts: 1
Solution Grade: A
 
 
[+][-]01.31.2005 at 08:22AM PST, ID: 13183944

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.31.2005 at 08:24AM PST, ID: 13183972

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.01.2005 at 08:44AM PST, ID: 13194371

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.02.2005 at 04:34AM PST, ID: 13202372

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-42