Chesterisanerd Posted January 14, 2007 Share Posted January 14, 2007 I've been searching all day, and I'mstill not clear..If I want to sort by the header row, Irealize there needs to be a link to the sortorder and column name, but I've seen about20 different variations, and I can't seem tofind a working combination of code.Please help, I've been doing PHP for a week.Thanks!file is called index.php and the columnsare listed below.[code]<?php// Connect to Databasemysql_connect("mysql", "NAME", "PASSWORD") or die(mysql_error());mysql_select_db("DATABASE") or die(mysql_error());$data = mysql_query("SELECT * FROM TABLE")or die(mysql_error());// Begin sql tablePrint "<table border=3 bgcolor=669999 bordercolor=333333 cellpadding=3 >";// Top row before calling sql dataPrint "<tr>";Print "<td>" . "<b>id#</b>" . "</td> ";Print "<td>" . "<b>Song</b>" . "</td> ";Print "<td>" . "<b>Artist</b>" . "</td> ";Print "<td>" . "<b>Album</b>" . "</td> ";Print "<td>" . "<b>Kilobytes</b>" . "</td> ";Print "<td>" . "<b>Date</b>" . "</td> ";Print "<td>" . "<b>Style</b>" . "</td>";Print "<td>" . "<b>Notes</b>" . "</td></tr>";Print "</text>";// Rows from sql while($info = mysql_fetch_array( $data )){Print "<tr>";Print "<td>".$info['id'] . "</td> ";print "<td><a href='{$info['link']}'>{$info['song']}</a>";Print "<td>".$info['artist'] . "</td> ";Print "<td>".$info['album'] . "</td> ";Print "<td>".$info['filesize'] . "</td> ";Print "<td>".$info['date'] . "</td> ";Print "<td>".$info['style'] . "</td> ";Print "<td>".$info['notes'] . "</td> </tr>";} Print "</table>";?>[/code] Link to comment https://forums.phpfreaks.com/topic/34170-sorting-question/ Share on other sites More sharing options...
c4onastick Posted January 14, 2007 Share Posted January 14, 2007 I'd leave it up to MySQL. MySQL is great for these kinds of things.[code]SELECT * FROM TABLE ORDER BY __insert_column_name_here__[/code]So for example:[code]SELECT * FROM table ORDER BY artist[/code] Link to comment https://forums.phpfreaks.com/topic/34170-sorting-question/#findComment-160759 Share on other sites More sharing options...
Chesterisanerd Posted January 14, 2007 Author Share Posted January 14, 2007 Thank you, so where do I put that?I'm slowly learning the basic rules of php. Link to comment https://forums.phpfreaks.com/topic/34170-sorting-question/#findComment-160774 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.