为了账号安全,请及时绑定邮箱和手机立即绑定

死循环,求大神帮忙!!!?实在看不出来

死循环,求大神帮忙!!!?实在看不出来

PHP
赵昊昊 2017-09-06 15:35:19
<?php header('content-type:text/html;charset=utf8'); class mysql{ var $hname; var $uname; var $uwpd; var $port; var $charset; var $dbname; public function __construct($hostname,$uname,$uwpd,$port,$charset,$dbname)//构造函数 { $this->hname=$hostname; $this->uname=$uname; $this->uwpd=$uwpd; $this->port=$port; $this->charset=$charset; $this->dbname=$dbname; } public function connect() { mysql_connect($this->hname,$this->uname,$this->uwpd); mysql_set_charset($this->charset); mysql_select_db($this->dbname); } public function query($sql) { return mysql_query($sql); } public function num_rows($sql) { $query=mysql_query($sql); return mysql_num_rows($query); } public function Allfetch($sql) { $arr=array(); $query=mysql_query($sql); while($rs=mysql_fetch_assoc($query)) { $arr[]=$rs; } return $arr; } public function fetch($sql) { $rs=array(); $query=mysql_query($sql); return $rs=mysql_fetch_assoc($query); } } $db=new mysql('localhost','root','root','3306','utf8','zhuce'); $db->connect(); $sql="select * from admin where 1 "; ?> <table border="1"> <tr> <td>用户名:</td> <td>密码:</td> </tr> <?php while($db->Allfetch($sql)){ ?> <tr> <td><?php echo $arr['user']; ?></td> <td><?php echo $arr['pwd']; ?></td> </tr> <?php }?> </table>
查看完整描述

1 回答

已采纳
?
phper_linuxer

TA贡献16条经验 获得超25个赞

<?php
while($db->Allfetch($sql)){
?>


这里你得把结果集取出来再循环啊,你这是循环取结果集,不是死循环是啥....................

<?php

$all_result = $db->Allfetch($sql);

foreach($all_result as $result) {

?>


查看完整回答
1 反对 回复 2017-09-07
  • 1 回答
  • 0 关注
  • 1328 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信