Yet again I'm in trouble
This don't compute .... 🙁
echo "<td bgcolor=silver class=medium onMouseOver="this.style.backgroundColor='#000000'; this.style.cursor='hand'; this.style.color='#FFFFFF'"
onMouseOut="this.style.backgroundColor=''; this.style.color='#000000'" onClick="window.location.href=\"{$_SERVER['PHP_SELF']}?order=$id1\">$id1</td>";
HELP .... how do I have multipule "s and 's in an echo 😕
I wanted to add more CSS thingies too the table to make it nice nicer 🙂
Shipdata
I added some sorting 😉
<?php
//Default_value
$default_sort = 'Race';
/* if order is not set, then set it to a default value. Otherwise,
* set it to what was passed in. */
if (!isset ($_GET['order'])) {
$order = $default_sort;
} else {
$order = $_GET['order'];
}
$hostname = "mysql1.freepaq.dk";
$username = "bax.dk";
$password = "X08sxCVR";
$dbName = "bax_dk_db";
MYSQL_CONNECT($hostname,$username,$password) or DIE("DATABASE FAILED TO RESPOND.");
mysql_select_db($dbName) or DIE("Table unavailable");
if ($order == 'Race'){
$sql = "SELECT *, (Race='Minmatar') as boolsort from bax_dk_db.Ships ORDER BY boolsort DESC, Race";
}
else if ($order == 'Class'){
$sql = "SELECT *, (Class='Rookieship') as boolsort from bax_dk_db.Ships ORDER BY boolsort DESC, Class";
}
else {
$sql = "SELECT * FROM bax_dk_db.Ships ORDER BY $order";
}
$result = mysql_query($sql);
$lastrace = 0;
echo "<html><head>
<title>Data for table (Ships)</title>
<style type='text/css'>
<!--
.normal { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; font-weight: normal; color: #000000}
.medium { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; color: #000000; text-decoration: none}
.headerlink { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; color: #FFFFFF; text-decoration: none; backgroundColor=#000000}
--></style>
</head><body><table border=1>";
while ($row = mysql_fetch_array($result)) {
$fc = mysql_num_fields($result);
if ($order == 'Race' || $order == 'Class'){
if ($row[$order] != $lastdimz) {
// output your header row
echo "<tr>";
for( $i=1;$i<$fc-1;$i++ )
{
$id1 = mysql_field_name( $result , $i );
echo "<td bgcolor=silver class='medium'><a href=\"{$_SERVER['PHP_SELF']}?order=$id1\">$id1</a></td>";
}
echo "</tr>";
}
$lastdimz = $row[$order]; //update value of lastdimz
// output ship data
echo "<tr>";
for( $i=1;$i<$fc-1;$i++ )
{
$id = mysql_field_name( $result , $i );
echo "<td class='normal' valign='top'>".$row[$id].'</td>';
}
echo "</tr>";
}
else {
if ($lastdimz%15 == 0) {
// output your header row
echo "<tr>";
for( $i=1;$i<$fc;$i++ )
{
$id1 = mysql_field_name( $result , $i );
echo "<td bgcolor=silver class='medium'><a href=\"{$_SERVER['PHP_SELF']}?order=$id1\">$id1</a></td>";
}
echo "</tr>";
}
$lastdimz++; //update value of lastdimz
// output ship data
echo "<tr>";
for( $i=1;$i<$fc;$i++ )
{
$id = mysql_field_name( $result , $i );
echo "<td class='normal' valign='top'>".$row[$id].'</td>';
}
echo "</tr>";
}
}
echo "</table></body></html>";
?>
Shipdata