假设我有一个如下所示的代码:
while ($info = mysql_fetch_assoc($data_p)) {
$name = stripslashes($info['name']);
$desc = stripslashes($info['description']);
$desc = substr($desc, 0, 150);
$price = stripslashes($info['price']);
Print "<div style=\"width:600px; height:150px; border:1px solid black; overflow:hidden\"><div style=\"height:148px; width:25%; border:1px solid red; float:left\"><center><img src=\"".$picture."\" height=\"120\" width=\"120\" style=\"margin-top:15px\" /></center></div><div style=\"height:150px; width:50%; border:1px solid blue; float:left; text-overflow: ellipsis; padding-top:5px\"><center><font size=\"+1\"><b><a href=\"result.php?product=".urlencode($name)."\">".$name."</b></a></font><br><br>".$desc."...</center></div><div style=\"height:150px; width:24%; border:1px solid green; float:left\"><center><h1>$".$price."</h1><button>Add to Cart</button></center></div></div>";
在 while 循环中首先定义的主 DIV 我想交替使用两种灰色阴影。所以在结果中它看起来像浅色深浅深色等......我尝试简单地用不同的颜色再次重复回声,但这会重复每个结果。有没有办法做到这一点?