Jump to content

Sorting question..


Chesterisanerd

Recommended Posts

I've been searching all day, and I'm
still not clear..

If I want to sort by the header row, I
realize there needs to be a link to the sort
order and column name, but I've seen about
20 different variations, and I can't seem to
find a working combination of code.

Please help, I've been doing PHP for a week.

Thanks!

file is called index.php and the columns
are listed below.

[code]<?php
// Connect to Database
mysql_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 table
Print "<table border=3 bgcolor=669999 bordercolor=333333 cellpadding=3 >";

// Top row before calling sql data
Print "<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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.