kool_samule Posted November 9, 2009 Share Posted November 9, 2009 Hi Chaps, I have a SQL Query: 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%20reco rd?');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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.