Use static to realize the color display of the table in alternate rows
We use PHP to query the data from the database and output the results to the browser. If the result has many rows and the bgcolor of the table is all monochrome, the viewer will feel uncomfortable. So how to make the colors of each row of the table different?
Please see below:
function getcolor()
{
static $colorvalue;//Define a static variable
if($colorvalue=="#ffffff")
$colorvalue="#000000";
else $colorvalue="#ffffff";
return($colorvalue);
}
print("
$i | n" );
The above introduces stefano ricci's use of static to realize the interlaced display of table colors, including the content of stefano ricci. I hope it will be helpful to friends who are interested in PHP tutorials.