How to extract multiple pieces of data from the database. the database has multiple pieces of data, but there is always only one piece (the younger brother used php for the first time). below is my database connection code PHPcodepublicfunctionquerySql ($ SQL) {$ data_array = how to retrieve multiple data entries from the database
There are multiple data records in the database, but there is always only one record (the younger brother used php for the first time). The following is the connection code of my database.
PHP code
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 "database connection error";} else {$ arrary = mysql_fetch_array ($ query);} $ close = @ mysql_close ($ connect) or die ("Unable to close database server connect! "); Return $ arrary ;}
------ Solution --------------------
PHP code
...} Else {while ($ r = mysql_fetch_array ($ query) $ arrary [] = $ r ;}....
------ Solution --------------------
Else {
While ($ arrary = mysql_fetch_array ($ query, MYSQL_ASSOC )){
Var_dump ($ arrary );
}
}
------ Solution --------------------
PHP code
else{ $arry = array(); while($arr = @mysql_fetch_array($result,MYSQL_ASSOC)){ array_push($arry,$arr); } return $arry;}