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:

 0) { foreach ($arr_news_category as $val) { echo ""; echo ""; echo ""; ?> "; } } else { 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!

1746.png


Continuing Learning
||
0){ $sql = "insert into new_category (name) values ('{$_POST['name']}')"; $result = mysqli_query($link,$sql); if ($result){ echo "添加成功!"; header("Location:category_list.php"); }else{ echo "添加失败~"; echo mysqli_error($link); exit; } } ?>
分类列表
ID 分类名 操作
{$val['id']}{$val['name']}
暂无记录!
0) { foreach ($arr_news_category as $val) { echo ""; echo ""; echo ""; ?> "; } } else { echo ""; } ?>
ID 分类名 操作
{$val['id']}{$val['name']}
暂无记录!
首页 1 ){ ?> 上一页 下一页 末页 / 总页码 页 当前页码
添加内容
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!