Home>Article>Backend Development> Implementation method of php mysql query display
php Mysql query display implementation method: first define a "ShowTable" method; then connect to the database through "mysql_connect"; then use "mysql_query" and other functions to query the database; finally, display and output the query results in a table .
Recommended: "PHP Video Tutorial"
PHP queries the MySql database and outputs the results in a table Example
When using PHP to develop a website, MySql database query results are output in tables, which may be difficult for students who are new to PHP program development.
This article uses an example to demonstrate the function of PHP querying the MySql database and outputting the results in a table. I hope it will be helpful to everyone's PHP programming.
"; echo "共计".$rows."行 ".$colums."列
"; echo ""; for($i=0; $i < $colums; $i++){ $field_name=mysql_field_name($res,$i); echo "$field_name "; } echo " "; while($row=mysql_fetch_row($res)){ echo ""; for($i=0; $i<$colums; $i++){ echo "$row[$i] "; } echo " "; } echo "
"; } ShowTable("test1"); ?>
The above is the detailed content of Implementation method of php mysql query display. For more information, please follow other related articles on the PHP Chinese website!