php怎么才能无限循环,PHP无限循环问题

更新时间:2023-06-21 01:46:44 阅读: 评论:0

php怎么才能⽆限循环,PHP⽆限循环问题
我可以使⽤正确的代码来⼯作,但是我希望能够使⽤对象和⽅法,但是这是⾏不通的.重复数据库中的相同条⽬,直到查询崩溃.我看到其他⼈在while语句中有查询,但是我认为我使⽤的⽅法应该只查询⼀次该语句,但是很可能是错误的.谢谢.
include '/functions/MySQL.php';
$MySQL = new MySQL;
$con = mysqli_connect("host","ur","password","db");
colour怎么读bigbigworld下载$result = mysqli_query($con,"SELECT * FROM reportLogger WHERE Moderator='jackginger'");
while($row = mysqli_fetch_array($MySQL->getReports('jackginger'))) {
$time = $row['Time'];
$moderator = $row['Moderator'];
$reason = $row['Reason'];
delegates
// Now for each looped row
insulinecho "
".$time."".$moderator."".$reason."";
长沙新东方英语
}
>
独⽴班
public function __construct(){
$this->con = mysqli_connect("localhost","root","pass","Minecraft");
感慨的意思my summer holiday英语作文// Check connection
curtains
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
}
public function getUUID($urname) {
$result = mysqli_query($this->con,"SELECT UUID FROM loginLogger WHERE Urname='" . $urname . "'");
return mysqli_fetch_array($result)[0];
子法}
pointtopublic function getReports($urname) {
$result = mysqli_query($this->con,"SELECT * FROM reportLogger WHERE UUID='" . $this->getUUID($urname) . "'");
return $result;
}
解决⽅法:
每次调⽤while($row = mysqli_fetch_array($MySQL-> getReports(‘jackginger’)))时,您都在进⾏新查询,因此它⼀次⼜⼀次地获取相同的内容.
⼀个解决⽅案可能是:
include '/functions/MySQL.php';
$MySQL = new MySQL;
$con = mysqli_connect("host","ur","password","db");
$result = mysqli_query($con,"SELECT * FROM reportLogger WHERE Moderator='jackginger'"); $store = $MySQL->getReports('jackginger');
while($row = mysqli_fetch_array($store)) {
$time = $row['Time'];
$moderator = $row['Moderator'];
$reason = $row['Reason'];
// Now for each looped row
echo "
".$time."".$moderator."".$reason."";
}
>
标签:mysqli,mysql,php,databa
来源: /bug/20191121/2052301.html

本文发布于:2023-06-21 01:46:44,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/78/1002551.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:查询   循环   可能   语句   崩溃
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图