Here is what I did. I have this script order the items from a MySQL DB by the period. Hope this example helps. It doesnt put it into a table....but its possible.
<?
$db_name = "learning_log";
$table_name = "users";
$connection = @mysql_connect("localhost", "root", "") or die(mysql_error());
$db = @mysql_select_db($db_name, $connection) or die(mysql_error());
$userlist = "<ul>";
//# -- Begin Learning Log Links -- #//
$sql1 = "SELECT id, period, f_name, l_name FROM $table_name WHERE period = 1 ORDER BY l_name";
$result1 = @mysql_query($sql1, $connection) or die(mysql_error());
#---------------------------------------------------
$userlist .= "<li>1<sup>st</sup> Period:</li><ul>";
#---------------------------------------------------
while ($row1 = mysql_fetch_array($result1))
{
$id1 = $row1['id'];
$period1 = $row1['period'];
$f_name1 = $row1['f_name'];
$l_name1 = $row1['l_name'];
$userlist .= "<li type=\"circle\"><a href=\"main.php?page=show_log&id=$id1\">$l_name1, $f_name1</a>";
}
$sql2 = "SELECT id, period, f_name, l_name FROM $table_name WHERE period = 2 ORDER BY l_name";
$result2 = @mysql_query($sql2, $connection) or die(mysql_error());
#---------------------------------------------------
$userlist .= "</ul><li>2<sup>nd</sup> Period:</li><ul>";
#---------------------------------------------------
while ($row2 = mysql_fetch_array($result2))
{
$id2 = $row2['id'];
$period2 = $row2['period'];
$f_name2 = $row2['f_name'];
$l_name2 = $row2['l_name'];
$userlist .= "<li type=\"circle\"><a href=\"main.php?page=show_log&id=$id2\">$l_name2, $f_name2</a>";
}
$sql3 = "SELECT id, period, f_name, l_name FROM $table_name WHERE period = 3 ORDER BY l_name";
$result3 = @mysql_query($sql3, $connection) or die(mysql_error());
#---------------------------------------------------
$userlist .= "</ul><li>3<sup>rd</sup> Period:</li><ul>";
#---------------------------------------------------
while ($row3 = mysql_fetch_array($result3))
{
$id3 = $row3['id'];
$period3 = $row3['period'];
$f_name3 = $row3['f_name'];
$l_name3 = $row3['l_name'];
$userlist .= "<li type=\"circle\"><a href=\"main.php?page=show_log&id=$id3\">$l_name3, $f_name3</a>";
}
$sql4 = "SELECT id, period, f_name, l_name FROM $table_name WHERE period = 4 ORDER BY l_name";
$result4 = @mysql_query($sql4, $connection) or die(mysql_error());
#---------------------------------------------------
$userlist .= "</ul><li>4<sup>th</sup> Period:</li><ul>";
#---------------------------------------------------
while ($row4 = mysql_fetch_array($result4))
{
$id4 = $row4['id'];
$period4 = $row4['period'];
$f_name4 = $row4['f_name'];
$l_name4 = $row4['l_name'];
$userlist .= "<li type=\"circle\"><a href=\"main.php?page=show_log&id=$id4\">$l_name4, $f_name4</a>";
}
$sql5 = "SELECT id, period, f_name, l_name FROM $table_name WHERE period = 5 ORDER BY l_name";
$result5 = @mysql_query($sql5, $connection) or die(mysql_error());
#---------------------------------------------------
$userlist .= "</ul><li>5<sup>th</sup> Period:</li><ul>";
#---------------------------------------------------
while ($row5 = mysql_fetch_array($result5))
{
$id5 = $row5['id'];
$period5 = $row5['period'];
$f_name5 = $row5['f_name'];
$l_name5 = $row5['l_name'];
$userlist .= "<li type=\"circle\"><a href=\"main.php?page=show_log&id=$id5\">$l_name5, $f_name5</a>";
}
$sql6 = "SELECT id, period, f_name, l_name FROM $table_name WHERE period = 6 ORDER BY l_name";
$result6 = @mysql_query($sql6, $connection) or die(mysql_error());
#---------------------------------------------------
$userlist .= "</ul><li>6<sup>th</sup> Period:</li><ul>";
#---------------------------------------------------
while ($row6 = mysql_fetch_array($result6))
{
$id6 = $row6['id'];
$period6 = $row6['period'];
$f_name6 = $row6['f_name'];
$l_name6 = $row6['l_name'];
$userlist .= "<li type=\"circle\"><a href=\"main.php?page=show_log&id=$id6\">$l_name6, $f_name6</a>";
}
$userlist .= "</ul></ul>";
?>
<html>
<head>
<title></title>
<link href="main.css" type="text/css" rel="stylesheet">
</head>
<body>
<center>
<h1>Current Learning Logs in the system</h1><br>
</center>
<? echo "$userlist"; ?>
</body>
</html>
NOTE: There is probably an easier way to do this.
~ROSEBLOOD