如何修改我的代码以允许我在 for each 循环中运行第二个查询?
现在我已经注释掉了第二个查询,因为我确定我需要在删除斜杠之前进行一些更改。
<?php
$mysqli = new mysqli('LOGIN DETAILS HERE');
if ($mysqli->connect_error) {
die('Connect Error: ' . $mysqli->connect_error);
}
$query = "SELECT * FROM toptips WHERE userid = 2";
$result = $mysqli->query($query);
while($row = $result->fetch_array())
{ $rows[] = $row; }
foreach($rows as $row) {
$id = $row['id'];
echo $row['time'] . " " . $row['course'] . " - " . $row['horse'] . " " . $row['description'] ."<br/>";
// second query here
// $query2 = "SELECT likes FROM Likes_table WHERE id = $id";
// $result = $mysqli->query($query2);
// while($row = $result->fetch_assoc()){
// echo $row['likes'] . '<br />';
// }
}
?>