Rumah > Artikel > pembangunan bahagian belakang > php while循环退不出是什么有关问题
php while循环退不出是什么问题?
<?php <br />include('include/config.php');<br />include('include/dbclass.php');<br />session_start();<br /><br /><br />$db = db::getInstance(); <br /> // $db->check_user_login(); //检查用户是否登录<br />$db->createcon(); //建立连接<br />// $user=$_SESSION["user"];<br />$user = "libero"; //测试临时使用<br />// 执行 user数据表 选取user数据<br />$sql_user = "select * from user where user = '$user'";<br />$user_array = $db->fetch_array($sql_user);<br /><br /><br /><br /><br />// 执行 yytable 数据 获取 yytable 所有数据<br />$sql_yytable = "select * from yytable where uid = '$user_array[0]'";<br /><br />echo "<table border = '1'>" ;<br /><br />while($yytable_array = $db->fetch_array($sql_yytable)){<br /> echo "<tr>";<br /> echo "<td>".$yytable_array[0]."</td>";<br /> echo "<td>".$yytable_array[1]."</td>";<br /> echo "<td>".$yytable_array[2]."</td>";<br /> echo "<td>".$yytable_array[3]."</td>";<br /> echo "<td>".$yytable_array[4]."</td>";<br /> echo "<td>".$yytable_array[5]."</td>";<br /> <br /> <br /> echo "</tr>";<br /> }<br /><br /><br /><br />echo "</table>";<br /><br />//dbclass<br /><br /><?php <br />class db{<br /> private static $dbhost = "localhost";<br /> private static $dbuser = "root";<br /> private static $password = "";<br /> private static $dbname = "yy";<br /> private static $instance = NULL;<br /> <br /> <br /> // 构造函数<br /> private function _construct(){}<br /> // 实例化<br /> public static function getInstance(){<br /> if (self::$instance == null){<br /> self::$instance = new db();<br /> }<br /> return self::$instance;<br /> }<br /> //连接数据库<br /> public function mycon(){<br /> @mysql_connetc(self::$dbhost,self::$dbuser,self::$password);<br /> <br /> }<br /> //选择数据库 <br /> public function selectdb(){<br /> $mysql_select_db(self::$dbname);<br /> <br /> }<br /> <br /> //创建连接 连接数据库<br /> public function createcon(){<br /> <br /> mysql_connect(self::$dbhost,self::$dbuser,self::$password);<br /> mysql_select_db(self::$dbname);<br /> }<br /> <br /> <br /> // 根据查询条件获取 $sql 结果集<br /> public function fetch_array($sql){<br /> <br /> if($result = $this->query($sql))<br /> {<br /> $rs = mysql_fetch_array($result, MYSQL_BOTH);<br /> return $rs;<br /> <br /> }<br /> else { echo "数据查询失败"; }<br /> <br /> }<br /> <br /> // 数据库查询执行语句<br /> public function query($sql){<br /> mysql_query("set names utf8");<br /> return mysql_query($sql);<br /> }<br /> <br /> // loop 更具结果集 获取数组<br /> <br /> public function loop_query($result){<br /> return mysql_fetch_array($result);<br /> <br /> <br /> }<br /> <br /> <br /> <br /> <br /> //关闭数据库连接<br /> <br /> public function close(){<br /> <br /> return mysql_close(); <br /> <br /> } <br /> <br /> <br /> <br /> }<br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> }<br /> <br /> <br /> <br /> <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />?><br /><br /><br />
<br> public function fetch_all($sql){<br> if($result = $this->query($sql))<br> {<br> while($r = mysql_fetch_array($result, MYSQL_BOTH)) {<br> $res[] = $r;<div class="clear"> </div>