Hi, nnichols:
Thanks for your input/efforts here, but still a loose screw somewhere...I've re-tweaked & retweaked and now got everything to work EXCEPT the 'alternating row colors' when there are multiple vendors in a category.
I just put together a quick test db (dbname=catventel):
--TEST Table1
drop table if exists table1;
CREATE TABLE table1 (
ID int(11) NOT NULL auto_increment primary key,
categorytype varchar(30) default NULL,
vendorname varchar(40) default NULL,
phonenumber varchar(15) default NULL
);
INSERT INTO table1 (ID, categorytype, vendorname, phonenumber) VALUES
(1,'APPRAISERS','Appraiser Name','(111)222-2222'),
(2,'CARPET CLEANING','Carpet Cleaner Name','(222)333-3333'),
(3,'CHIMNEY & FIREPLACE','Chimney Service #1','(333)444-4444'),
(4,'CHIMNEY & FIREPLACE','Chimney Service #2','(444)555-5555'),
(5,'CHIMNEY & FIREPLACE','Chimney Service #3','(444)555-5555');
RE:
<?
?>
<html>
<head>
<title>RECOMMENDED VENDORS</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<STYLE type=text/css>FORM {
DISPLAY: inline
}
TABLE {
background-color: #000000;
}
TH {
background-color: #000000;
FONT-SIZE:10pt; COLOR: #FFFFFF; FONT-FAMILY: Verdana, Tahoma, Arial
}
TR {
FONT-SIZE: 8.5pt; COLOR: #000000; FONT-FAMILY: Verdana, Tahoma, Arial
}
TD {
FONT-SIZE: 8.5pt; COLOR: #000000; FONT-FAMILY: Verdana, Tahoma, Arial
}
.solidborder {
BORDER-RIGHT: #999999 1px solid; BORDER-TOP: #999999 1px solid; BORDER-LEFT: #999999 1px solid; BORDER-BOTTOM: #999999 1px solid
}
.rowcolheader {
background-color: #c1c1c1;
font-family: Arial, Helvetica, sans-serif;
font-size:14;
font-weight: bold;
text-decoration: none;
vertical-align: middle;
color: #FFFFFF;
LETTER-SPACING: 1px;
}
.datafontreg {
FONT-SIZE: 8.5pt; COLOR: #000000; FONT-FAMILY: Verdana, Tahoma, Arial;
text-decoration: none;
}
.datarow1 {
BACKGROUND-COLOR: #f2f2f2
}
.datarow2 {
BACKGROUND-COLOR: #d8d8d8
}
</STYLE>
</head>
<body>
<center>
<strong><font color="#000000" size="+2" face="Arial, Helvetica, sans-serif">RECOMMENDED VENDORS</font></strong>
</center>
<br>
<?
$user="me";
$host="localhost";
$password="";
$database="catventel";
$connection = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$db = mysql_select_db($database,$connection)
or die ("Couldn't select database");
$sql = "SELECT * FROM table1 ORDER BY categorytype ASC";
$result = mysql_query("$sql")
or die ("Couldn't execute query.");
$result = mysql_query("$sql")
or die ("Couldn't execute query.");
$numofrows = mysql_num_rows($result);
$i = 0;
while($row = mysql_fetch_array($result)) {
$i++;
$categorytype = $row['categorytype'];
$vendorname = $row['vendorname'];
$phonenumber = $row['phonenumber'];
if ($categorytype != $prev_cat && $prev_cat == NULL) {
// this condition occurs when it is the first iteration 'coz $prev_cat hasn't been set yet
echo "<CENTER><TABLE width=\"330\" cellspacing=\"1\" cellpadding=\"2\" BORDER=\"0\">\n";
echo "<TH colspan=\"2\">" . $categorytype . "</TH>\n";
echo "<TR class=\"rowcolheader\"><TD width=\"174\" align=\"center\"><B>VENDOR NAME</B></TD><TD width=\"135\" align=\"center\"><B>TELEPHONE</B></TD></TR>";
echo "<TR class=\"datarow1\"><td align=\"left\">" . $vendorname . "</td><td align=\"center\">" . $phonenumber . "</td></TR>\n";
} elseif ($categorytype == $prev_cat) {
echo "<TR class=\"datarow1\"><td align=\"left\">" . $vendorname . "</td><td align=\"center\">" . $phonenumber . "</td></tr>\n";
// check to see if this is the last row of the result set - if so, close last table
if ($i == $numofrows) {
echo "</TABLE></CENTER>\n";
echo "<br>";
}
} else {
echo "</TABLE></CENTER>\n";
echo "<CENTER><TABLE width=\"330\" cellspacing=\"1\" cellpadding=\"2\" BORDER=\"0\">\n";
echo "<TH colspan=\"2\">" . $categorytype . "</TH>\n";
echo "<TR class=\"rowcolheader\"><TD width=\"174\" align=\"center\"><B>VENDOR NAME</B></TD><TD width=\"135\" align=\"center\"><B>TELEPHONE</B></TD></TR>";
echo "<TR class=\"datarow1\"><td align=\"left\">" . $vendorname . "</td><td align=\"center\">" . $phonenumber . "</td></tr>\n";
echo "<br>";
}
$prev_cat = $row['categorytype'];
}
?>
</body>
</html>
<?
?>
Needs to look like: http://www.xgenesis.com/sample.html
...the 'alternating row colors' in the last table example
Thanks if you can figure out what's missing 'cuz I can't !!!