Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>i hope my code will be helpfull :</p> <pre><code>&lt;?php //in this example : //first you have to create a database with name : blog // create table : article (id as primary key, name , content) // here we supposed that in the content you have your tags &lt;!-- new page --&gt; // also i supposed the name of this file as : pagination.php //Getting the id of article: //========================= if(isset($_GET['id'])) $id_article = $_GET['id']; else $id_article = 1; //Connexion to database : //====================== $user="root"; $pass="root"; $db="blog"; $host="localhost"; $pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION; $bdd = new PDO('mysql:host='.$host.';dbname='.$db, $user, $pass, $pdo_options); $bdd-&gt;query("SET NAMES 'utf8'"); $response = $bdd-&gt;query('SELECT * FROM articles WHERE id='.$id_article); $tab_content = array(); $data = $response-&gt;fetch() echo'&lt;div &gt;'; $tab_content = explode('&lt;!-- new page --&gt;',$data['content']); $count_pages = count($tab_content); if($count_pages){ //in the case that you have somme tags : //===================================== echo $tab_content[$page]; echo '&lt;br&gt;'; for($i=1;$i&lt;$count_pages;$i++) echo '&lt;a href="./pagination.php?id='.$id_article.'&amp;page='.$i.'"&gt;'.$i.'&lt;/a&gt;&amp;nbsp;&amp;nbsp;'; } else{ //if no tags '&lt;!-- new page --&gt;' in your content: //=============================================== echo $data['content']; } echo '&lt;/div&gt;'; $response-&gt;closeCursor(); ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload