Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Zend_Paginator on mySql query using GET
    primarykey
    data
    text
    <p>I am trying to call pages using <code>Zend_Paginate()</code> on a query that loads based on a GET search string the query essentially does the following:</p> <pre><code>SELECT * FROM table WHERE column LIKE '%searchstring%' OR alt_column LIKE '%searchstring%'; </code></pre> <p>The query works fine when called via search/submit text form and the URL returns something similar to </p> <pre><code>URLINK.php?search=searchstring </code></pre> <p>However when trying to move onto the next page the program dumps me back to the paginate alternate URL (used for errors or no page display)-- hope this last line makes sense it is late and am doing my best to type this up with transparency.</p> <p>What is the best method when using paginate against <code>URL.php?search=searchstring</code>"?</p> <p>A bit more on the call to the url</p> <pre><code>//search query $search = searchQuery('search', 'list_sql_rows.php'); $results - searchTable($dbRead, $search); </code></pre> <p>search method using the variables above in the order below</p> <pre><code>if(isset($_POST['submit_search'])) { $searchstring = $_POST['searchstring']; if($searchstring) { header('Location: results.php?search=' . $searchstring); } } </code></pre> <p>This bit works well, but when I try to call the <code>results.php?page=2</code> with paginator the system reverts me to the fall back URL <code>list_sql_rows.php</code> as mentioned above. Any thoughts/comments are appreciated.</p> <p>Just to clarify a search field/form from the search.php page sends the <code>$searchstring</code> to the results.php page via <code>$_POST</code> &amp;&amp; <code>$_GET</code> as fail safe. The get method sends the <code>$searchstring</code> in the URL header so the results of the search DO work on the first page <strong><em>results.php?search=$searchstring</em></strong>. This works just fine. The pagination seems to lose the <code>$searchstring</code>, and I wonder if this is due to a loss of the <code>$_POST</code>/<code>$_GET</code> when paginator begins to 'paginate' it returns URL <strong><em>results.php?page=2</em></strong> so it seems <code>$_GET</code> may not be the method of choice? </p> <p><strong>UPDATE</strong> On the write track now paginate works it is my link structure that is broken. <strong>_results_samples.php?search=robert&amp;page=4_</strong> will in fact return page 4 of the paginated results using the word ROBERT</p> <p><em><strong>SOLUTION FOUND VIA variant suggestion by ROCKYFORD</strong></em> variant of recommended method by first persisting <code>$searchstring</code> change to paginate links as shown below </p> <pre><code>&lt;a href='" . $_SERVER['PHP_SELF'] . "?search=" . $searchstring . "&amp;page={$page}'&gt;$page&lt;/a&gt; </code></pre>
    singulars
    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.
    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