【发布时间】:2013-11-27 01:24:59
【问题描述】:
我需要不断循环浏览来自 Kiosk 的 MySQL 表的 14 个查询结果
显示每个结果 10 秒
PHP 或 JS 中的任何示例都会受到赞赏
现在我有 14 个 php 文件,我使用这个 meta http-equiv=\"refresh\" content=\"10; url=ccml2.php\" 循环浏览每个文件的页面都会更改以转到下一页,最后指向第一个。 但我认为必须有一种方法可以使用单个 php 文件来执行此操作。 每个查询都会更改 where on select 以获取需要显示的值。 例如从字段 3 = 值的表中选择字段 1、字段 2。 进行查询,显示结果 10 秒,更改为下一个值,重复。 值可以是 1 到 14
这是第一次尝试,但它没有做我认为应该做的事情
$mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = sprintf("SELECT ClassName, ClassId FROM class");
$result = $mysqli->query($query) or die($mysqli->error.__LINE__);
while($row = $result->fetch_assoc())
{
$ICName[]=$row['ClassName']; //gets 14 Class Names
$IC_Id[] = $row['ClassId']; // gets matching ID 1 to 14
}
for($x=0;$x<$result->num_rows;$x++)
{
echo "<html>";
echo "<body>";
echo "<head>";
echo "<Title>Cactus Combat Match League</Title>";
echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"ccml.css\" media=\"all\" />";
echo "</head>";
echo "<img width=\"1280\" height=\"190\" src=\"images/Banner.png\"></img>";
echo "<p></p>";
echo "<p></p>";
echo "<h2>Thursday Night Match Scores 11/14/2013</h2>";
echo "<table border=\"1\" width=\"1200\" align=\"center\">";
echo "<tr>";
echo "<th class=\"th1\" colspan = \"8\">".$ICName[$x]."</th>"; // Display Class Name
echo "</tr>";
echo "<tr>";
echo "<th class=\"th2\">#</th>";
echo "<th class=\"th2\">Name</th>";
echo "<th class=\"th2\">Stage 1</th>";
echo "<th class=\"th2\">Stage 2</th>";
echo "<th class=\"th2\">Stage 3</th>";
echo "<th class=\"th2\">Stage 4</th>";
echo "<th class=\"th2\">Stage 5</th>";
echo "<th class=\"th2\">TOTAL</th>";
echo "</tr>"; // following gets results for this Class
$query1 = sprintf("SELECT mid, SName, Stage1, Stage2, Stage3, Stage4, Stage5, Total FROM shooter WHERE cid=".$IC_Id[$x]." AND mdate='2013-11-14' ORDER BY Total");
$result1 = $mysqli->query($query1) or die($mysqli->error.__LINE__);
while ($row1 = $result1->fetch_assoc()) // Display Results
{
echo "<tr>";
echo "<td class=\"t1\">".$row1['mid']."</td>";
echo "<td class=\"t3\">".$row1['SName']."</td>";
echo "<td class=\"t2\">".number_format((float)$row1['Stage1'], 2, '.', '')."</td>";
echo "<td class=\"t2\">".number_format((float)$row1['Stage2'], 2, '.', '')."</td>";
echo "<td class=\"t2\">".number_format((float)$row1['Stage3'], 2, '.', '')."</td>";
echo "<td class=\"t2\">".number_format((float)$row1['Stage4'], 2, '.', '')."</td>";
echo "<td class=\"t2\">".number_format((float)$row1['Stage5'], 2, '.', '')."</td>";
echo "<td class=\"t4\">".number_format((float)$row1['Total'], 2, '.', '')."</td>";
echo "</tr>";
}
echo "</table>";
echo "</body>";
echo"</html>";
sleep(1);
}
mysqli_close($mysqli);
?>
【问题讨论】:
-
请给我们更多细节..
-
分享你现有的代码会有帮助
-
回复的那两个怎么回答?
-
现在我有 14 个 php 文件,我用这个 页面更改each 转到下一页,最后一个指向第一个。但我认为必须有一种方法可以使用单个 php 文件来执行此操作。每个查询都会更改 where on select 以获取需要显示的值。例如从字段 3 = 值的表中选择字段 1、字段 2。进行查询,显示结果 10 秒,更改为下一个值,重复。值可以是 1 到 14。
-
希望这有助于让它停止
标签: javascript php mysql