Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP如何每10行回显一个不同的图像_Php_Mysql_Sql_Echo_Counter - Fatal编程技术网

PHP如何每10行回显一个不同的图像

PHP如何每10行回显一个不同的图像,php,mysql,sql,echo,counter,Php,Mysql,Sql,Echo,Counter,我有一个简单的搜索引擎,它在一个带有CSS格式的表格中回显结果,这很好,但是,我现在想在每10个结果后回显一个不同的图像 感谢所有能帮助我的人,因为我已经在这个问题上纠缠了好几个小时了 这是我的回音输出代码: echo "<table width='50%' style='border-bottom:1px solid #000000;'"; echo "<tr>"; echo "<td>"; echo "<div id='page-wrap'>"; e

我有一个简单的搜索引擎,它在一个带有CSS格式的表格中回显结果,这很好,但是,我现在想在每10个结果后回显一个不同的图像

感谢所有能帮助我的人,因为我已经在这个问题上纠缠了好几个小时了

这是我的回音输出代码:

echo "<table width='50%' style='border-bottom:1px solid #000000;'";
echo "<tr>";
echo "<td>";
echo "<div id='page-wrap'>";
echo "<div class='discounted-item freeshipping'>";

echo "<a href='./img/users/" . $row['category'] . "/" . $row['username'] . "/" . $row['filename'] . "' rel='lightbox'><img src=\"./img/users/" . $row['category'] . "/" . $row['username'] . "/" . $row['filename'] . "\" alt=\"\" width='20%' height='98%' /></a>";


echo "<div class='reasonbar'><div class='prod-title' style='width: 70%;'>" .$row['fname'] . "</div><div class='reason' style='width: 29%;'><b>". $row['firstname'] . " " . $row['surname'] ."</b></div></div>";

echo "<div class='reasonbar'><div class='prod-title1' style='width: 70%;'>" . $row['lname'] . "</div><div class='reason1' style='width: 29%;'>Category: ". $row['category'] . "</div></div>";

echo "<div class='reasonbar'><div class='prod-title2' style='width: 70%;'>Contact:" . $row['contact'] . "</div><div class='reason2' style='width: 29%;'>Price: &pound;". $row['price'] . "</div></div>";


echo "</td>";
echo "</tr>";
echo "</td>";
echo "</tr>";
echo "</table>";
}

}

else
    echo "No results found for \"<b>$search</b>\"";

echo”您可以使用modolus运算符来确定

if ( ! ($i % 10)) {
    // Alternate.
}

如果您没有一个计数器变量可供使用,只需在循环外声明一个,并将其设置为
0
,并在每次迭代中递增它。

谢谢您的回复!我将在回音代码中的哪一点放置此变量?@NeilKumar条件可以在任何地方计算,但您可能希望将其放置在您需要的位置ant要回显另一个图像。我有点纠结于如何声明计数器,我认为它带有$I++;?但不确定将其放置在何处,以及在读取循环中的值后,如何计算循环外部和循环内部的结果数。