News classification list of PHP native development news station
In the previous lesson, we have completed the preparation of the news classification list. Including creating a database and inserting data. So today we will explain to you how to make a news category list display page. Then find our category management page in the background template~, and then delete the unnecessary and redundant code. !
After we have set up and modified the template, we start writing our program. First connect to the database:
selected db error!"; exit(); }
Then query the database and execute the SQL statement:
$sql = "select * from new_category where 1 "; // 查询语句 $result = mysqli_query($link, $sql); $arr_news_category = mysqli_fetch_all($result, MYSQL_ASSOC);
here We have fetched all the contents of the database, and now we need to traverse the fetched data and then display it:
ID
分类名
操作
0) { foreach ($arr_news_category as $val) { echo "
OK! The news classification list is complete, oh yes! There is also pagination here. The pagination here is the same as the news pagination. I won’t repeat it here. You can refer to the news pagination!
The courseware is not available for download at the moment. The staff is currently organizing it. Please pay more attention to this course in the future~
Students who have watched this course are also learning