Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

ORDER BY - Table headings

Guest
Nov 09, 2009 Nov 09, 2009

Hi Chaps,

I have a DreamWeaver recordset:

mysql_select_db($database_conndb2, $conndb2);
$query_rsProjects = "SELECT tbl_projects.projid, tbl_projects.projtitle, tbl_customers.custname, tbl_projects.projstart, tbl_projects.projdue, tbl_projects.projstatus, tbl_projects.projstatus, DATE_FORMAT(tbl_projects.projstart, '%d/%m/%Y') as projstart_format, DATE_FORMAT(tbl_projects.projdue, '%d/%m/%Y') as projdue_format, tbl_projects.projpriority FROM tbl_projects, tbl_customers WHERE tbl_projects.FK_custid=tbl_customers.custid AND tbl_projects.projstatus!='Complete' ORDER BY projid ASC";
$rsProjects = mysql_query($query_rsProjects, $conndb2) or die(mysql_error());
$row_rsProjects = mysql_fetch_assoc($rsProjects);
$totalRows_rsProjects = mysql_num_rows($rsProjects);

The data is presented in a table:

<table border="0" cellpadding="0" cellspacing="0" id="tblrepeat_proj">
      <caption>
        <img src="../Images/project.jpg" border="0" /><a href="project_add.php"><img src="../Images/new.jpg" border="0" /></a><a href="#" onclick="print()"><img src="../Images/print.jpg" border="0"/></a>
      </caption>
      <tr>
        <th scope="col">Order No.</th>
        <th scope="col">Document Name</th>
        <th scope="col">Customer</th>
        <th scope="col">Start Date</th>
        <th scope="col">Due Date</th>
        <th scope="col">Status</th>
        <th scope="col">Edit</th>
        <th scope="col">Remove</th>
      </tr>
      <?php do { ?>
      <td>
      <?php echo $row_rsProjects['projid']; ?></span></td>
          <td><a href="project_details.php?id=<?php echo $row_rsProjects['projid']; ?>"><?php echo $row_rsProjects['projtitle']; ?></a></td>
          <td><?php echo $row_rsProjects['custname']; ?></td>
          <td><?php echo $row_rsProjects['projstart_format']; ?></td>
          <td><?php echo $row_rsProjects['projdue_format']; ?></td>
          <td><?php echo $row_rsProjects['projstatus']; ?></span></td>
          <td><a href="project_edit.php?id=<?php echo $row_rsProjects['projid']; ?>">Edit</a></td>
          <td><a href="project_remove.php?id=<?php echo $row_rsProjects['projid']; ?>" onclick="tmt_confirm('Are%20you%20sure%20you%20want%20to%20delete%20this%20record?');return document.MM_returnValue">Remove</a></td>
        </tr>
        <?php } while ($row_rsProjects = mysql_fetch_assoc($rsProjects)); ?>
    </table>

Is it possible to use the table headings as the control for the ORDER BY in the SQL query?

TOPICS
Server side applications
432
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Nov 09, 2009 Nov 09, 2009

You can, but I find it usually more user friendly to use client side sorting for tables. It's much faster and easy to implement. Just search for client side table sort. Here's one example.

http://www.glendinning.org/webbuilder/sortTable/

Translate
LEGEND ,
Nov 09, 2009 Nov 09, 2009

You can, but I find it usually more user friendly to use client side sorting for tables. It's much faster and easy to implement. Just search for client side table sort. Here's one example.

http://www.glendinning.org/webbuilder/sortTable/

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 09, 2009 Nov 09, 2009
LATEST

That's exactly what I'm after . . .I'll try and use something like that,

thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines