The first is my database:
Then show me the PHP file:
1 b.php File:2<?PHP3 4 5$link = Mysqli_connect ('localhost','Root','Root');6 //mysqli_character_set_name ();7Mysqli_query ($link,"Set names UTF8");8mysqli_select_db ($link,'THKPHP5');9$sql ='SELECT * from Zixun';Ten$result =mysqli_query ($link, $sql); One$records =Array (); A while($record =Mysqli_fetch_array ($result)) { - //the mysql_fetch_array () function acts like the function of a foreach array: traversal (Result set) - //each time it goes to the result set of "row of data" and "loads" into the array $record the //The index of the array is the field name of the Select, and the value is the data value of the corresponding row -$records []=$record; - } - //Var_dump ($records); +Require'login.html'; - //Why can that smooth show, that require ' login.html ', is to copy the login.html page into this b.php file
?>
Then the HTML file:
1<!--template files, displaying data with HTML code--2<! DOCTYPE html>3"en">45<meta charset="UTF-8">6<title> Competition List </title>78<body>9 Ten<table> One<tr> A<th>zx_id</th><th>zx_name</th><th>zx_fenlei</th><th>zx_zuozhe</th ><th> Update time </th><th> views </th><th> release Status </th> -</tr> -<?phpforeach($records as$row):?> the<tr> -<td><?php Echo $row ['zx_id'];? ></td> -<td><?php Echo $row ['Zx_name'];? ></td> -<td><?php Echo $row ['Zx_fenlei'];? ></td> +<td><?php Echo $row ['Zx_zuozhe'];? ></td> -<td><?php Echo $row ['Gengxin_time'];? ></td> +<td><?php Echo $row ['Liulan_cishu'];? ></td> A<td><?php Echo $row ['Fabu_zhuangtai'];? ></td> at</tr> -<?php Endforeach;? > -</table> -</body> -The final results show:
php,php) reads data from the database and displays it in HTML