如何根据特定的电子邮件ID获取存储在mysqli数据库中的所有记录。
就像我想获得所有针对id@check.com存储的问题字段的记录一样,为了得到我到目前为止所做的事情,请参阅下文。但我的for循环代码仅打印www.google.com。我怎么能得到其他两个领域?
<?php
$email = $_SESSION["email"];
$prevq = "Select * FROM `askadoc` WHERE `email` = '$email'";
$result = mysqli_query($conn, $prevq);
$prevq = "";
$location = "";
if(mysqli_num_rows($result)>0){
while($row = mysqli_fetch_assoc($result)) {
$prevq = $row["question"];
$date = $row["date"];
}
}
?>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="home">
<?php
for($i=0; $i<=count($email); $i++){
echo $date;
echo "<br>";
echo $prevq;
echo "<br>";
}
?>
</div>
</div>
答案 0 :(得分:1)
只需在你的div中写下你的while loop
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="home">
<?php
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo $prevq = $row["question"];
echo $date = $row["date"];
}
}
?>
</div>
</div>
答案 1 :(得分:1)
试试这个会起作用:
cartesian sqx sqy