PHP develops a simple news release system to realize the overall function of the news list page
In the previous chapter, we talked about how to achieve a simple paging effect, so we won’t explain it in detail here.
First we need to display the news records in the database
Here we need to useselect field name 1, field 2, ... from data table nameto obtain News data
Display the obtained database data in the HTML page through a while loop
修改 删除
Note: The modification function and deletion function are implemented through id, specifically modify and delete the PHP code The implementation functions will be introduced in later chapters.
修改 删除
Here we have added a search function, we give a function$keyword,pass$_GETTo obtain data
To search for news titles and news content,need to use fuzzy search inSQL statements
Fuzzy search is mainly implemented through the LIKE (case-insensitive) keyword. LIKE conditions are generally used when specifying a field to search for, and the fuzzy search function is implemented through the use of "%" or "_" wildcard characters. The wildcard character can be in front of the field, or behind or both before and after the field.
There are three main types: like 'keyword%', like '%keyword', like'%keyword%'.
In order to implement the paging search function, we addedkeyword=
上一页| |下一页in the HTML paging code
Show the complete list.php code:
0) { //获取的页数有余 $countPage = ceil($countNews/$limitNews); // ceil()函数向上舍入为最接近的整数,除不尽则取整数+1页, 10个新闻每个页面显示3个,成3个页面,剩余1个成1个页面 } else { $countPage = $countNews/$limitNews; } $prev = ($page - 1 <= 0 )?1:$page-1; $next = ($page + 1 > $countPage)?$countPage:$page+1; $result = mysqli_query($link, $sql); ?>新闻列表页
编号 | 文章标题 | 文章作者 | 文章内容 | 发布时间 | 修改时间 | 编辑文章 |
---|---|---|---|---|---|---|
修改 删除 |