如何从数据库中取出多条数据
本来数据库有多条数据,但是取出来始终只有一条(小弟第一次使用php),下面是我的数据库连接代码
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> public function querySql($sql){ $data_array = parse_ini_file("database.ini",true); $connect = @mysql_connect($data_array["url"],$data_array["username"],$data_array["pass"]) or die ("Unable to connect database server!"); mysql_query("set names '".$data_array["incode"]."'"); $query = mysql_db_query($data_array["basename"],$sql ,$connect); $arrary; if(!$query){ echo "数据库连接错误"; }else{ $arrary = mysql_fetch_array($query); } $close = @mysql_close($connect) or die ("Unable to close database server connect!"); return $arrary; }
...... }else{ while($r = mysql_fetch_array($query)) $arrary[] = $r; } ....<br><font color="#e78608">------解决方案--------------------</font><br>else{ <br>while($arrary = mysql_fetch_array($query,MYSQL_ASSOC)){<br> var_dump($arrary);<br>} <br>}<br><font color="#e78608">------解决方案--------------------</font><br>
else{ $arry = array(); while($arr = @mysql_fetch_array($result,MYSQL_ASSOC)){ array_push($arry,$arr); } return $arry;}<div class="clear"> </div>