NoDoze Posted December 8, 2006 Share Posted December 8, 2006 ok, I search these forums for answers but each solution was different, and from the looks of it, the code contained shortcuts....cause it doesn't make sense to me...I don't get it...SO, I'm going to post my code, and hopefully someone could help me :)I need these columns, when the header is clicked, the column is sorted by that header.[code]<html><head><style type="text/css"><!--a:link , a:visited { color: #FFFFFF; text-decoration: none;}a:hover { color: #000000; text-decoration: none;}.table { font-family: Arial; font-size: 12px; color: #FFFFFF; text-decoration: none; text-align: center; border: 1px solid #FFFFFF; width: 100%;}.table-header { font-family: Arial; font-size: 12px; font-weight: bold; color: #FFFFFF; text-decoration: none; text-align: center; background-color: #0554A3;}.tf { background-color: #3399CC;}--></style></head><body><table class="table"><tr class="table-header"><td><a href="pil-view.php?sortby=id">ID</a></td><td><a href="pil-view.php?sortby=date">Initiation Date</a></td><td><a href="pil-view.php?sortby=project_number">Project Number</a></td><td><a href="pil-view.php?sortby=resposible_individual">Responsible Individual</a></td><td><a href="pil-view.php?sortby=project_description">Project Description</a></td><td><a href="pil-view.php?sortby=country">County</a></td><td><a href="pil-view.php?sortby=region">Region</a></td><td><a href="pil-view.php?sortby=client">Client</a></td></tr></body></html><?include 'config.php';include 'opendb.php';$query="SELECT * FROM pil";$result=mysql_query($query);mysql_close();$num=mysql_numrows($result);$i=0;while ($i < $num) {$id=mysql_result($result,$i,"id");$date=mysql_result($result,$i,"date");$project_number=mysql_result($result,$i,"project_number");$resposible_individual=mysql_result($result,$i,"resposible_individual");$project_description=mysql_result($result,$i,"project_description");$county=mysql_result($result,$i,"county");$region=mysql_result($result,$i,"region");$client=mysql_result($result,$i,"client");// alternate #8F8F8F with #000000print ($i % 2) ? "<tr bgcolor=\"6699CC\">" : "<tr bgcolor=\"3399CC\">";print "<td>$id</td>";print "<td>$date</td>";print "<td>$project_number</td>";print "<td>$resposible_individual</td>";print "<td>$project_description</td>";print "<td>$county</td>";print "<td>$region</td>";print "<td>$client</td>";++$i;}include 'closedb.php';?>[/code]Any help is appreciated, thanks! Link to comment https://forums.phpfreaks.com/topic/29982-sort-by-table-column/ Share on other sites More sharing options...
drifter Posted December 8, 2006 Share Posted December 8, 2006 $query="SELECT * FROM pil";if(isset($_GET['sortby'])){$query .= " ORDER BY '" . $_GET['sortby'] . "'";}$result=mysql_query($query); Link to comment https://forums.phpfreaks.com/topic/29982-sort-by-table-column/#findComment-137773 Share on other sites More sharing options...
NoDoze Posted December 8, 2006 Author Share Posted December 8, 2006 Ahhh, ya posted right when I was posting! heheI figured it out on my own! :)Thanks for the help :) Link to comment https://forums.phpfreaks.com/topic/29982-sort-by-table-column/#findComment-137776 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.