How does PHP assign column values of database tables to arrays?
Source: Internet
Author: User
How does PHP assign column values of database tables to arrays? $ Myquery = @ mysql_query (& quot; select * fromdb_select & quot;) ordie (& quot; query statement execution failed! & Quot;); $ cnt = mysql_num_rows ($ myquery); for ($ I = 0; $ I & lt; $ c PHP how to assign the column values of database tables to arrays?
$ Myquery = @ mysql_query ("select * from db_select ")
Or die ("query statement execution failed! ");
$ Cnt = mysql_num_rows ($ myquery );
For ($ I = 0; $ I <$ cnt; $ I ++ ){
Echo "". mysql_result ($ myquery, $ I, 0 )."";
}
Currently, all values in column 0 of the database are saved in mysql_result. how can I assign the values in mysql_result to an array $ arr?
In addition, I think the form of mysql_result ($ myquery, $ I, 0) is too troublesome. can I start with the query statement directly,
$ Myquery = @ mysql_query ("select the columns I need from db_select"), and then simplify mysql_result ($ myquery, $ I, 0) to mysql_result ($ myquery, $ I )?
New to PHP, I hope experts can answer this question.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.