Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Personally, if I knew I wouldn't ever really have more than 5 pages or so, I would forgo the Ajax thing altogether... Not that I don't like it... I just don't think its necessary in this case.</p> <pre><code>&lt;?php // Example Database result (say, 2 "pages" worth)... // We'll pretend the cells in your database match the textarea names... $results = array( [0] =&gt; array( 'textbox1'=&gt;'abc', 'textbox2'=&gt;'def', 'textbox3'=&gt;'ghi', 'textbox4'=&gt;'jkl', 'textbox5'=&gt;'mno', 'textbox6'=&gt;'pqr' 'textbox6'=&gt;'stu' 'textbox6'=&gt;'vwx' ), [1] =&gt; array( 'textbox1'=&gt;'cba', 'textbox2'=&gt;'fed', 'textbox3'=&gt;'ihg', 'textbox4'=&gt;'lkj', 'textbox5'=&gt;'onm', 'textbox6'=&gt;'rqp' 'textbox6'=&gt;'uts' 'textbox6'=&gt;'xwv' ) ) $json_results = json_encode($results); ?&gt; &lt;!-- Generate some jQuery and HTML --&gt; &lt;script language="javascript"&gt; var pages = eval('&lt;?=$json_results;?&gt;'); $(function() { $('.page_num').live('click',function() { var page = $(this).attr('rel'); if(pages[page] &amp;&amp; pages[page].length &gt; 0) { $.each(pages[page],function(key,value) { // assuming your key names are the same as the // names of your textareas $('textarea[name="'+key+'"]').value(value); }); } else { alert("Oops, that page doesn't exist for some reason..."); } }); }); &lt;/script&gt; &lt;?php foreach($results[0] as $key=&gt;$value): ?&gt; &lt;textarea name="&lt;?=$key?&gt;"&gt;&lt;?=$value;?&gt;&lt;/textarea&gt; &lt;?php endforeach; ?&gt; &lt;div id="page_nums"&gt; &lt;?php for($i=1;$i&lt;=sizeof($results)-1;$i++): ?&gt; &lt;a class="page_num" href="#" rel="&lt;?=$i;?&gt;"&gt;&lt;?=$i;?&gt;&lt;/a&gt; &lt;?php endfor; ?&gt; </code></pre>
    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.
    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