Alright I have a script that lets you create a table of items using MySQL, and then sorting them by name or price or whatever. here is the script:
<?php
$username = "ffextreme";
$password = "dellpops";
$hostname = "localhost";
$database_name = "ffextreme_com";
/* connect to db */
mysql_connect ($hostname,$username,$password);
mysql_select_db ($database_name);
$default_sort = 'name';
$allowed_order = array ('" . $_POST["name"] . "', '" . $_POST["info"] . "', '" . $_POST["price"] . "');
if (!isset ($_GET['order']) ||
!in_array ($_GET['order'], $allowed_order)) {
$order = $default_sort;
} else {
$order = $_GET['order'];
}
if ($displaytable == "ffxaccessories") {
if(!$_GET['order_by']) {
$query = "SELECT name, price, description, location FROM $displaytable ORDER BY name";
} else {
$order_by = $_GET['order_by'];
$query = "SELECT name, price, description, location FROM $displaytable ORDER BY $order_by"; }
}
if ($displaytable == "ffxitems") {
if(!$_GET['order_by']) {
$query = "SELECT name, price, description FROM $displaytable ORDER BY name";
} else {
$order_by = $_GET['order_by'];
$query = "SELECT name, price, description FROM $displaytable ORDER BY $order_by"; }
}
$result = mysql_query($query) or die();
$numrows = mysql_num_rows($result);
if ($numrows == 0) {
echo "No data to display!";
exit;
}
$row = mysql_fetch_assoc ($result);
echo "<TABLE width=80% cellspacing=1 cellpadding=5 bgcolor=#000000 border=0>\n";
echo "<TR>\n";
foreach ($row as $heading=>$column) {
echo "<a href=index.php?displaytable=$displaytable&order_by=$heading><TD bgcolor=#395060 onmouseout=\"style.backgroundColor='#395060'\"; onmouseover=\"style.backgroundColor='#6A778A'; style.cursor='hand'\"><b>";
if (in_array ($heading, $allowed_order)) {
echo "<font face=Verdana size=1 color=#CCCCCC>$heading</font>";
} else {
echo "<font face=Verdana size=1 color=#CCCCCC>$heading</font>";
}
echo "</b></TD></a>\n";
}
echo "</TR>\n";
mysql_data_seek ($result, 0);
while ($row = mysql_fetch_assoc ($result)) {
echo "<TR bgcolor=565E6B>\n";
foreach ($row as $column) {
echo "<TD><font face=Verdana size=1 color=#CCCCCC><strong>$column</strong></font></TD>\n";
}
echo "</TR>\n";
}
echo "</TABLE>\n";
?>
But now I have to figure out how to have it organize by Name or Price again, but using complex tables, like the ones here:
http://www.ffonline.com/ff7/enemies-ab.htm (click the little arrows at the sides of each)
I have it so the entire cell with the title (Name or whatever) can be clicked to organize it by that field..
I'm not sure what to do that will let me do something like this, since my program is based on a "one row per item" thing, maybe in each row could be another table... but then how could I get the fields to show and be organized...
My question is pretty much how do I do this?