Note that there are some explanatory texts on larger screens.

plurals
  1. POphp- Paginate data from array
    primarykey
    data
    text
    <p>I am making a WordPress plugin to integrate with our library system. I am trying to create a page with a search form to search the database. I have created an API on our library server (it is on our local network) so the site can interface with our library back end.</p> <p>I am trying to paginate results pulled from the API, the data is in json. I have created the following code to get the json from the API and turn it into a PHP array, it does not implement search, yet:</p> <pre><code>add_shortcode("book_search_form", "book_search_form"); function book_search_form() { $api_url = get_option('api_url'); $api_key = get_option('api_key'); $data = file_get_contents("$api_url/book/index.php/name/awesome/$api_key"); $data = (array)json_decode($data, true); echo '&lt;pre&gt;'; var_dump($data); echo '&lt;/pre&gt;'; } </code></pre> <p>here is the output:</p> <pre><code>array(2) { [0]=&gt; array(22) { ["barcode"]=&gt; string(12) "000015427928" ["name"]=&gt; string(74) "Janice VanCleave's 201 awesome, magical, bizarre &amp; incredible experiments." ["author"]=&gt; string(12) "Janice Pratt" ["author_last"]=&gt; string(9) "VanCleave" ["publisher"]=&gt; string(11) "Wiley: 1994" ["year_pub"]=&gt; string(0) "" ["edition"]=&gt; string(0) "" ["genre"]=&gt; string(0) "" ["checkout"]=&gt; string(5) "false" ["series"]=&gt; string(0) "" ["callnum"]=&gt; string(5) "507.8" ["fiction"]=&gt; string(5) "false" ["in_house"]=&gt; string(5) "false" ["timestamp"]=&gt; string(10) "1374711656" ["outto"]=&gt; string(0) "" ["duedate"]=&gt; string(1) "0" ["ISBN"]=&gt; string(10) "0585339376" ["media_type"]=&gt; string(0) "" ["print"]=&gt; string(5) "false" ["BOXID"]=&gt; string(0) "" ["uid"]=&gt; string(1) "0" ["printed"]=&gt; string(4) "true" } [1]=&gt; array(22) { ["barcode"]=&gt; string(12) "000015429634" ["name"]=&gt; string(50) "Our Awesome Earth: Its Mysteries and Its Splendors" ["author"]=&gt; string(4) "Paul" ["author_last"]=&gt; string(6) "Martin" ["publisher"]=&gt; string(35) "Natl Geographic Society: March 1994" ["year_pub"]=&gt; string(0) "" ["edition"]=&gt; string(0) "" ["genre"]=&gt; string(0) "" ["checkout"]=&gt; string(5) "false" ["series"]=&gt; string(0) "" ["callnum"]=&gt; string(3) "050" ["fiction"]=&gt; string(5) "false" ["in_house"]=&gt; string(5) "false" ["timestamp"]=&gt; string(10) "1382550052" ["outto"]=&gt; string(0) "" ["duedate"]=&gt; string(1) "0" ["ISBN"]=&gt; string(10) "0870445456" ["media_type"]=&gt; string(0) "" ["print"]=&gt; string(5) "false" ["BOXID"]=&gt; string(0) "" ["uid"]=&gt; string(1) "0" ["printed"]=&gt; string(5) "false" } } </code></pre> <p>I am trying to create pagination, because some of the queries contain 50 or more books. I have done this before with mysql but I cannot figure out how to do it with an array.</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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