Title: Autopagination with php?
Last modified: August 21, 2016

---

# Autopagination with php?

 *  Resolved [Andreas 2013](https://wordpress.org/support/users/andreas-2013/)
 * (@andreas-2013)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/autopagination-with-php/)
 * Hello, I’m filling my wordpress-pages from a mysql-database. Now I tried to split
   the very long text-content with <!–nextpage–> automatically with the following
   code:
    —————————————————
 *     ```
       <? $SQLString = "SELECT name, address FROM Table WHERE id = '$id'";
       $Ergebnis = mysql_db_query("db_name", $SQLString,$Verbindung);
       $Datensatz = mysql_fetch_array($Ergebnis);
   
       if(mysql_num_rows($Ergebnis)>0) {
   
       $counter=0;
       while ($Datensatz) {
   
       echo "<div>".$Datensatz['name'].$Datensatz['address']."</div>";
       $Datensatz = mysql_fetch_array($Ergebnis);
   
       $counter++;
       if(($counter%10)==0) {
       echo "<!--nextpage-->";
       }
       else {
       echo "";
       }
   
       }
       }
       ?>
       ```
   
 * —————————————————
 * But this didn’t work in wordpress.
    What about this plugin, could it solve my
   problem to make pagebreaks automatically in combination with php/mysql? Or is
   there another way to do this job?
 * Thank you for your answers 🙂
 * Andreas
 * [https://wordpress.org/plugins/page-links-single-page-option/](https://wordpress.org/plugins/page-links-single-page-option/)

Viewing 15 replies - 1 through 15 (of 22 total)

1 [2](https://wordpress.org/support/topic/autopagination-with-php/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/autopagination-with-php/page/2/?output_format=md)

 *  Plugin Author [Studio Hyperset](https://wordpress.org/support/users/studiohyperset/)
 * (@studiohyperset)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/autopagination-with-php/#post-4786886)
 * Hi, Andreas:
 * Yes, the Page-Links Plus auto pagination module helps automate page breaks without
   splitting sentences or words or creating widows, orphans, or trailing headers.
 * The current version allows users to split by number of paragraphs, but we’ll 
   soon be releasing a new version that allows users to split by paragraphs, number
   of words, and total number of pages (ie., “I want this post to = x number of 
   total pages).
 * Thanks for your interest in PLP.
 *  Plugin Author [Studio Hyperset](https://wordpress.org/support/users/studiohyperset/)
 * (@studiohyperset)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/autopagination-with-php/#post-4786888)
 * PS, you can demo the plugin here, if you like:
 * [http://demo.pagelinksplus.com/wp-login.php](http://demo.pagelinksplus.com/wp-login.php)
 *  Thread Starter [Andreas 2013](https://wordpress.org/support/users/andreas-2013/)
 * (@andreas-2013)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/autopagination-with-php/#post-4786903)
 * Thank you for your answer. It’s difficult for me, to check this on the demo-account,
   because I need to use the database-connection.
    Nevertheless, I tried to make
   a long post manually, and it was automatically splitted, when I used <p>-tags.
   But not, if I use <div>-tags. Which tags are supported, can you tell me more 
   about this? Thank you!
 *  Plugin Author [Studio Hyperset](https://wordpress.org/support/users/studiohyperset/)
 * (@studiohyperset)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/autopagination-with-php/#post-4786920)
 * Hi, Andreas:
 * I’m not entirely sure I understand your issue or your question, but if you install
   the PLP auto pagination module in a WP environment and structure your content
   according to best-practices HTML tagging, it will automatically paginate content
   for you.
 *  Thread Starter [Andreas 2013](https://wordpress.org/support/users/andreas-2013/)
 * (@andreas-2013)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/autopagination-with-php/#post-4786921)
 * Yes, but I want to split the text on special points. I have many, many <div>-
   Container and want to split the content BETWEEN the div’s. Is this possible?
 *  Plugin Author [Studio Hyperset](https://wordpress.org/support/users/studiohyperset/)
 * (@studiohyperset)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/autopagination-with-php/#post-4786922)
 * Hi, Andreas:
 * Probably the best thing to do would be to test a sample of your markup on the
   demo site.
 * Whether it works or doesn’t work, can you post a sample of it here? I’d like 
   to see what you’re trying to accomplish and the structure of your copy/markup.
 * Thanks!
 *  Thread Starter [Andreas 2013](https://wordpress.org/support/users/andreas-2013/)
 * (@andreas-2013)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/autopagination-with-php/#post-4786926)
 * The php/database-connection-code see above. This will generate following text-
   boxes:
 *     ```
       <div>
       <a target="_blank" href="http://www.mydomain.de"><img src="http://www.mydomain.de/image.jpg"></a>
       <p><strong>text</strong></p>
       <p>text text text</p>
       <p>text text text text text text text</p><p><a href="http://www.mydomain.de"">text text text</a></p>
       </div>
       ```
   
 * So I want to split between those div’s.
 *  Plugin Author [Studio Hyperset](https://wordpress.org/support/users/studiohyperset/)
 * (@studiohyperset)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/autopagination-with-php/#post-4786928)
 * Hi, Andreas:
 * PLP will split based on the paragraphs, not the <div>’s. As such, if you had 
   the sort of code you outline above, PLP will insert a page break after _x_ number
   of paragraphs (_x_ being the variable you provide).
 * Please note that, to prevent splitting sentences or words or creating widows,
   orphans, or trailing headers, PLP won’t accept values lower than “3.” There’s
   no upper limit, though.
 * Again, the best way to test your particular code blocks would be to use the demo
   site. You can test different scenarios on pages, posts, and custom post types.
 * Thanks!
 *  Thread Starter [Andreas 2013](https://wordpress.org/support/users/andreas-2013/)
 * (@andreas-2013)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/autopagination-with-php/#post-4786934)
 * Thank you again. I would like to test on the demo account, but without database
   I can’t proof it 🙁
 * It’s late, may be till tomorrow 😉
 *  Thread Starter [Andreas 2013](https://wordpress.org/support/users/andreas-2013/)
 * (@andreas-2013)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/autopagination-with-php/#post-4786965)
 * Hello again!
    I made a page on your demo-account and connected then to mysql-
   database on my webhoster (Code works in wordpress). This is the code:
 *     ```
       <? $Verbindung = mysql_connect("XXXX", "XXXX", "XXXX");
       mysql_query("SET NAMES 'utf8'");
       mysql_query("SET lc_time_names = 'de_DE'");
       $SQLString = "SELECT * FROM testtabelle";
       $Ergebnis = mysql_db_query("XXXX", $SQLString,$Verbindung);
       $Datensatz = mysql_fetch_array($Ergebnis);
       if(mysql_num_rows($Ergebnis)>0) {
       while ($Datensatz) {
   
       echo "<p><strong>".$Datensatz['column1']."</strong><br>".$Datensatz['column2']."</p>";
       $Datensatz = mysql_fetch_array($Ergebnis);
       }
       }
       else {
       echo "no matches";
       }
       ?>
       ```
   
 * Unfortunately the php-Code wasn’t parsed 🙁
    Is this not allowed in demo-modus?
 *  Plugin Author [Studio Hyperset](https://wordpress.org/support/users/studiohyperset/)
 * (@studiohyperset)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/autopagination-with-php/#post-4786992)
 * Hi, Andreas:
 * Are you pasting PHP into the page/post editor?
 * If so, no, the demo won’t accommodate this, but neither will any WP instance 
   without some customization. (The demo is intentionally built to be as “vanilla”
   as possible.)
 * If you were to build the above into a theme template, PLP would probably still
   auto paginate the content. However, I’ve no idea how the other features would
   work. PLP is essentially a glorified hook for the wp_link_pages function ([http://codex.wordpress.org/Function_Reference/wp_link_pages](http://codex.wordpress.org/Function_Reference/wp_link_pages)),
   and I’ve only tested it narrowly outside the context of this function.
 * Is there a reason you’re injecting content using the above vs. using the WP loop?
   Just out of curiosity, what’s your thinking re: this approach?
 *  Plugin Author [Studio Hyperset](https://wordpress.org/support/users/studiohyperset/)
 * (@studiohyperset)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/autopagination-with-php/#post-4786993)
 * _Duplicate post._
 *  Thread Starter [Andreas 2013](https://wordpress.org/support/users/andreas-2013/)
 * (@andreas-2013)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/autopagination-with-php/#post-4786994)
 * Hello, thanks for your answer. Yes, I pasted in the Editor in text-modus (is 
   there another way for text-input?)
    I’m only unsure, if your plugin works with
   my code, because I tested a free plugin, which had similar features (auto-pagination),
   and this plugin didn’t work! So if your plugin works the same way, there will
   be no results too. That’s my problem. Your last sentence I didn’t understand 
   unfortunately. My code is actually very normally for connecting to a database.
   Or what did you mean exactly (my english is very bad, sorry)?
 *  Plugin Author [Studio Hyperset](https://wordpress.org/support/users/studiohyperset/)
 * (@studiohyperset)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/autopagination-with-php/#post-4786997)
 * Hi, Andreas:
 * This is a very specialized, unique instance, and I just don’t understand enough
   about what you’re trying to do to make sense of it.
 * My sense is PLP would auto paginate your content, but if your theme doesn’t include
   the wp_link_pages function, other features probably won’t work.
 * Best of luck going forward.
 *  Thread Starter [Andreas 2013](https://wordpress.org/support/users/andreas-2013/)
 * (@andreas-2013)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/autopagination-with-php/#post-4786998)
 * The wp_link_pages function works, I checked it out with <!–nextpage –>.
    Whatever,
   I think the only way to find it out, is to buy the plugin. What do I have to 
   do, is there a download after payment available? How do I have to pay?

Viewing 15 replies - 1 through 15 (of 22 total)

1 [2](https://wordpress.org/support/topic/autopagination-with-php/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/autopagination-with-php/page/2/?output_format=md)

The topic ‘Autopagination with php?’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/page-links-single-page-option_812b2a.
   svg)
 * [WordPress Pagination Plugin: Page-Links Plus](https://wordpress.org/plugins/page-links-single-page-option/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/page-links-single-page-option/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/page-links-single-page-option/)
 * [Active Topics](https://wordpress.org/support/plugin/page-links-single-page-option/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/page-links-single-page-option/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/page-links-single-page-option/reviews/)

 * 22 replies
 * 2 participants
 * Last reply from: [Andreas 2013](https://wordpress.org/support/users/andreas-2013/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/autopagination-with-php/page/2/#post-4787022)
 * Status: resolved