Try this an correct for your MySQL DB :
<?
// Invertion of backgroud color
function usecolorbkg()
{
static $colorbkg;
if($colorbkg == "#0080C0")
{
$colorbkg = "#FEFAF1";
}
else
{
$colorbkg = "#0080C0";
}
return($colorbkg);
}
//
// Invertion of font color
//
function usecolorfont()
{
static $colorfnt;
if($colorfnt == "#FEFAF1")
{
$colorfnt = "#004080";
}
else
{
$colorfnt = "#FEFAF1";
}
return($colorfnt);
}
//
// Create the cell in table for First row
//
function printtitle($printarg)
{
print("<TH align=center bgcolor=\"#004080\"><font face=\"Arial\" size=\"2\" color=\"#FEFAF1\">");
print("$printarg");
print("</font></TH>\n");
}
//
// Create the cell in table for each line
//
function printline($printarg, $alignement, $bkg, $fnt, $wrap)
{
print("<TD align=$alignement $wrap bgcolor=\"$bkg\"><font face=\"Arial\" size=\"2\" color=\"$fnt\">");
print("$printarg");
print("</font></TD>\n");
}
//BEGIN OF PHP Programm
//
// Imprimer le Debut de la page HTML !! (pour faire croire a du HTML Reel)
//
//Data for TEST
$rechref = "%CPU%";
$wheresearch = "REF";
$searchvalue = "";
if($rechercheavancee <> "")
{
$wheresearch = "DESIGNATION";
$rechref = "%$rechercheavancee%";
}
elseif($rechref == "")
{
$rechref = "%";
}
$errcont = 1; //Boolean to check errors
// Ouvrir la database avec un utilisateur "lecture seule"
$mysqllink = mysql_connect("YOURSERVER OR IP", "USERNAME", "PASSWORD");
// Traitement d'erreur d'ouverture...
$errno = mysql_errno($mysqllink);
$error = mysql_error($mysqllink);
if($errno <> 0)
{
$errcont = 0;
print ("Error $errno : $error<BR>\n");
print ("Veuillez contacter le WEBMASTER par e-mail...<BR>\n");
}
else
{
$mysqlselect = mysql_select_db("ecs", $mysqllink);
$errno = mysql_errno($mysqllink);
$error = mysql_error($mysqllink);
if ($errno <> 0)
{
$errcont = 0;
print ("Error $errno : $errot<BR>\n");
print ("Veuillez contacter le WEBMATER par e-mail...<BR>\n");
}
}
//If NO ERROR EXECUTE ELSE GOTO END !
if($errcont == 1)
{
// CREATE THE QUERY
//
$query = "SELECT * FROM LISTE_PRIX where $wheresearch like \"$rechref\"";
$mysqlresult = mysql_query($query, $mysqllink);
// MEMORIZE NUBER OF AFFECTED ROWS
$nbrarg = mysql_affected_rows($mysqllink);
//CRONTROL DATA TO BE SUPPRESSED IN FINAL VERSION
print("QUERY : $query <BR>");
print("Result : $mysqlresult <BR>");
print("NBRARG : $nbrarg <BR>");
print("MYSQLLINK : $mysqllink <BR>");
print("MYSQLSELECT : $mysqlselect <BR>");
//BEGIN OF TABLE
print("<TABLE width=\"500\" cellpadding=\"5\" cellpadding=\"5\" align=\"center\">\n");
print("<TR>\n");
printtitle("REF");
printtitle("DESIGNATION");
printtitle("Luf TTC");
printtitle("Euro TTC");
printtitle("FrF TTC");
printtitle("Info");
print("</TR>\n");
//READ EACH RECORD AND CREATE EACH ROW IN TABLE
for($compteur = 1; $compteur <= $nbrarg; $compteur++)
{
$row = mysql_fetch_array($mysqlresult);
$bkgcolor = usecolorbkg();
$fntcolor = usecolorfont();
print("<TR>\n");
printline($row["REF"], "left", $bkgcolor, $fntcolor, "nowrap");
printline($row["DESIGNATION"], "left", $bkgcolor, $fntcolor, "");
printline($row["Luf_ttc"], "right", $bkgcolor, $fntcolor, "");
printline($row["Euro_ttc"], "right", $bkgcolor, $fntcolor, "");
printline($row["FrF_ttc"], "right", $bkgcolor, $fntcolor, "");
if($row["Comment"] <> "")
{
printline($row["Comment"], "center", $bkgcolor, "#FF0000", "");
}
else
{
printline("-", "center", $bkgcolor, $fntcolor, "");
}
print("</TR>\n");
}
// END OF TABLE
print("</TABLE>\n");
}
mysql_close($mysqllink);
?>
If You want, send me an e-mail to get the code !
To see it working, you can go on my test server :
http://test.sit-net.lu
(sorry this site is in french)
Andre,
Luxembourg
Europe