我正在尝试在 3 个相邻<div>
容器中显示 3 个单独查询的结果。三个查询如下:
$query="SELECT * FROM students WHERE WeekOne='employer'";
$query="SELECT * FROM students WHERE WeekTwo='employer'";
$query="SELECT * FROM students WHERE WeekThree='employer'";
期望的输出:
第一周 ----- 第二周 ----- 第三周
结果 1 ---------- 结果 1 ------------ 结果 1
结果 2 ---------- 结果 2 ----------- 结果 2 (等等...)
有人可以帮我吗?我已经看过 PHP 手册上的 multi_query,但不知道如何实现它。非常感谢。
@Emmanuel G
<?
$user = "xx";
$user_password = "xx";
$db_name = "xx";
$db = new mysqli ("xx", $user, $user_password, $db_name);
$queries = array(
"SELECT * FROM students WHERE WeekOne='$Name'",
"SELECT * FROM students WHERE WeekTwo='$Name'",
"SELECT * FROM students WHERE WeekThree='$Name'"
);
// iterate through the queries and their results
foreach($queries as $query){
$result = $mysqli->query($query);
echo '<div>'; // open that div up
while($row = $result->fetch_assoc()){ // gives u an array hoorah!
echo '<pre>'.print_r($row, true).'</pre>'; // just to look at it
echo "<p>{$row['FirstName']}</p>"; // just an example
}
echo '</div>'; // close it up
}
?>