I am pretty new to mySQL, and I am unsure of how to proceed.
I have a php script at http://everythinghotrod.com/inventory/mainpage.php. What i want to do is have the text in the header cells bold with the background red, while the remaining row colors will alternate between white and light gray, to make reading easier.
Also, I only want an outer border on the table, which I want to be solid black, with no internal borders. I only want the border to be 1px.
The code that I am using is as follows;
<?php
// Set the variables for the database
$Host = "localhost";
$User = "username";
$Password = "passwd";
$DBName = "db_name"; // Database name
$TableName = "table_name"; // Name of table to display
// Do not edit below this line
$Link = mysql_pconnect ($Host, $User, $Password);
if ( $Pagesize ) {
if( !$start ) $start = 1;
pagination($start,$Link,$DBName,$TableName,$Pagesize);
$PaginationQuery = "LIMIT " . $start . ", " . $Pagesize;
}
$Query = "SELECT * FROM $TableName " . $PaginationQuery;
$Result = mysql_db_query ($DBName, $Query, $Link);
// Create a table with headers.
print ("<TABLE BORDER=1>\n");
print ("<TR>\n");
for ($i = 0; $i < mysql_num_fields($Result); $i++) {
print "<TD>".mysql_field_name($Result, $i)."</TD>\n";
}
print ("</TR>\n");
// Fetch the results from the database.
while ($Row = mysql_fetch_array ($Result)) {
print ("<TR>\n");
for ($i = 0; $i < mysql_num_fields($Result); $i++) {
print "<TD>$Row[$i]</TD>\n";
}
print ("</TR>\n");
}
print ("</TABLE>\n");
mysql_close ($Link);
function pagination($start,$Link, $DBName, $TableName, $Pagesize) {
if ( !$Pagesize ) return;
$Query = "SELECT count(*) as count FROM $TableName";
$Result = mysql_query($Query);
$row = mysql_fetch_array($Result);
$numrows = $row['count'];
if($start >= $Pagesize) {
echo "<a href=\"" . $PHP_SELF . "?Pagesize=$Pagesize&start=" . ($start - $Pagesize) .
"\">Previous</a> | \n";
} else {
echo "Previous | \n";
}
if($numrows > ($start + $Pagesize)) {
echo "<a href=\"" . $PHP_SELF . "?Pagesize=$Pagesize&start=" . ($start + $Pagesize) .
"\">Next</a>\n";
} else {
echo "Next | \n";
}
print "Page " . floor(($start / $Pagesize)+1);
print " of " . ceil(($numrows / $Pagesize));
print " | " . $numrows . " Records";
}
php?>
Any help would be greatfully appreciated.
Thanks!
-Brett