Home > Backend Development > PHP Tutorial > 怎么从数据库中取出多条数据

怎么从数据库中取出多条数据

WBOY
Release: 2016-06-13 10:20:27
Original
1475 people have browsed it

如何从数据库中取出多条数据
本来数据库有多条数据,但是取出来始终只有一条(小弟第一次使用php),下面是我的数据库连接代码

PHP code
<!--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;         }
Copy after login




------解决方案--------------------
PHP code
            ......            }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>
Copy after login
PHP code
else{  $arry = array();  while($arr = @mysql_fetch_array($result,MYSQL_ASSOC)){    array_push($arry,$arr);  }  return $arry;}<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template