Backend Development
PHP Tutorial
[php mysql] Blog paging production ideas, phpmysql paging ideas_PHP tutorial
[php mysql] Blog paging production ideas, phpmysql paging ideas_PHP tutorial
[php mysql] Blog paging production ideas, phpmysql paging ideas
1. First, you need to initialize and set the number of articles displayed on each page $page_size, the total number of articles in the mysql database $ arc_size, number of pages $page
2. Use paging formula
(current page number - 1) In the data table, query the content starting from n out to n m out.3. Display the contents of the database The code is as follows: <?php $conn = @mysql_connect("localhost","root","liujiang") or die("Failed to connect to database server!"); //Connect ly_php_base Database
$ok = @mysql_select_db("myblog_base",$conn) or die("Failed to connect to the database!");
mysql_query("set names 'utf8'"); //Solve the mysql database The problem of failure to insert Chinese characters into . Please note that utf8 must be consistent with <meta charset="utf-8">
if($ok){echo "mysql is ok!";}else {echo " mysql is failed!";}
$page=$_GET['page'];//Get the current page value
if (!isset($page)){$page=1;} //If If there is no value, assign 1
$page_size=2;//Display 2 items per page
$arcs_result=mysql_query("select count(*) as total from myblog_article");//The output result is Resource id # 4
$arc_size=mysql_result($arcs_result,0,"total");//Total number of articles
$pagenum=ceil($arc_size/$page_size);
$offset=($page-1) *$page_size;
$sql=mysql_query("SELECT * FROM myblog_article WHERE 1 order by id asc limit $offset,$page_size");
//desc means descending order, which means starting from $offset, sorting $page_size times
if($sql){echo "query yes";}else {echo "query no";}
$rs=mysql_fetch_array($sql); //Extract data
while($ rs) {
?>
<div>
<p>Article title:<?php echo $rs['title'];?><p>
<p>Article type:<?php echo $rs['style'];?></p>
<p>Article introduction:<?php echo $rs['abstract'];?></p>
<p>Upload time:<?php echo $rs['date'];?></p> ;
<p>Article author:<?php echo $rs['author'];?>[<?php echo $page;?>]page</p>
</div>
<?php $rs = mysql_fetch_array($sql);
}
For($i=1;$i<=$pagenum; $i ){
$show=($i!=$page)?"<a href='index1.php?page=".$i."'>$i< /a>":"<b>$i</b>";
Echo $show." ";
}?>
http://www.bkjia.com/PHPjc/1096604.html
Hot AI Tools
Undress AI Tool
Undress images for free
AI Clothes Remover
Online AI tool for removing clothes from photos.
Undresser.AI Undress
AI-powered app for creating realistic nude photos
ArtGPT
AI image generator for creative art from text prompts.
Stock Market GPT
AI powered investment research for smarter decisions
Hot Article
Popular tool
Notepad++7.3.1
Easy-to-use and free code editor
SublimeText3 Chinese version
Chinese version, very easy to use
Zend Studio 13.0.1
Powerful PHP integrated development environment
Dreamweaver CS6
Visual web development tools
SublimeText3 Mac version
God-level code editing software (SublimeText3)
Hot Topics
20529
7
13638
4
How to configure the number of log retention days in mysql_mysql expire_logs_days setting
Apr 08, 2026 pm 09:45 PM
expire_logs_days has been abandoned in MySQL5.7.6, binlog_expire_logs_seconds should be used instead; this parameter only cleans the binlog and does not affect other logs; it requires double settings of the configuration file SETGLOBAL, and cooperates with regular PURGE or crontab cleanup.
How to use SHOW PROCESSLIST to view the process of mysql_mysql active connection monitoring
Apr 08, 2026 pm 10:06 PM
SHOWPROCESSLIST returns the connection snapshot visible to the current user. The key fields include Id (thread ID), User (user name), Host (IP port), and State (current operation). PROCESS permission plus ALL is required to see all connections. Root also needs explicit authorization. It is recommended to use performance_schema.threads instead.
How does mysql solve the leftmost match of the joint index_mysql query structure adjustment
Apr 08, 2026 pm 10:12 PM
The joint index only recognizes the leftmost prefix, because the B-tree must match continuously from the leftmost column; if the middle column is skipped (such as WHEREa=1ANDc=3 in the index (a,b,c)), the right column will be invalid, causing the key to be NULL or the key_len to be too small.
How to choose an engine for mysql under high concurrency_InnoDB and MyISAM load test analysis
Apr 08, 2026 pm 09:48 PM
Under high concurrency conditions, you should avoid using MyISAM and choose InnoDB. MyISAM only supports table-level locks, which can easily lead to write freezes. InnoDB row-level locks are more suitable for concurrency scenarios, but buffer_pool_size, disk flushing strategies, and transaction batch processing need to be properly configured to maximize performance.
How to quickly compare the permission differences of two users in mysql_MySQL permission export and comparison
Apr 08, 2026 pm 10:00 PM
To check permissions, you need to first confirm that the user exists and the context is correct. Because MySQL stores permissions according to the 'user'@'host' combination, users with the same name on different hosts have independent permissions. SHOWGRANTS does not display PROXY permissions, so you need to check mysql.proxies_priv. For export, it is recommended to use mysqldump or batch generate GRANT statements and standardize the format. Permission comparison must consider the effective priority, implicit denial and connection context.
MySQL Production Environment Selection Guide_How to choose a storage engine based on business scenarios
Apr 10, 2026 am 07:06 AM
MySQL8.0 has completely removed the MyISAM engine, and old tables need to be manually converted to InnoDB or Archive; InnoDB is the default and only safe choice, and buffer_pool_size and log_file_size need to be tuned; Archive is only suitable for pure read-only archiving; Memory is only for temporary calculation and will be lost upon restart.
How to check the last successful backup time in mysql_Query information_schema record
Apr 10, 2026 am 07:09 AM
MySQL does not automatically record the backup time, and the information_schema does not have a backup log table; the reliable methods are: check the backup file modification time, parse the mysqldump log, and query the self-built backup_records table.
How to handle triggers when MySQL deletes a table_DROP TABLE trigger logic description
Apr 10, 2026 am 07:12 AM
Triggers disappear automatically when a table is deleted, and there is no need to manually clean them up; MySQL will clear all triggers in the table when executing DROPTABLE, because they are dependent on the existence of the table and have no independent life cycle.





