Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to use the Pagination Class when some scripts in the controller are written in raw PHP
    primarykey
    data
    text
    <p>I have script to display database information without reloading the page. The script is working fine but the problem is I want to use the codeigniter's pagination class here and but since I have used some raw PHP in my controller, I don't know how to do this. Would you please kindly show me how to use the pagination class in my script?</p> <p>Thanks in Advance :)</p> <p>The scripts I have::</p> <p>Inside Head</p> <pre><code> &lt;script type="text/javascript"&gt; $(document).ready(function() { $("select[name='users']").attr("selectedIndex", 1); $("select[name='users']").change(function() { var str = $(this).val(); if( str == "" ) { $("#txtHint").html(""); } else { $.get("&lt;?php echo base_url(); ?&gt;test/query/"+ str, function(data) { $("#txtHint").html(data) }); } }).change(); }); &lt;/script&gt; </code></pre> <p>Inside Body</p> <pre><code> &lt;form&gt; &lt;select name="users" &gt; &lt;option value=""&gt;Select a person:&lt;/option&gt; &lt;option value="11080101"&gt;Sumon&lt;/option&gt; &lt;option value="11080102"&gt;Donno&lt;/option&gt; &lt;/select&gt; &lt;/form&gt; &lt;br /&gt; &lt;div id="txtHint"&gt;&lt;b&gt;Person info will be listed here.&lt;/b&gt;&lt;/div&gt; </code></pre> <p>My Controller:</p> <pre><code> function query($id){ $sql="SELECT * FROM attendancein WHERE attendeeid = '$id' "; $result = mysql_query($sql); echo "&lt;table border='1'&gt; &lt;tr&gt; &lt;th&gt;date&lt;/th&gt; &lt;th&gt;In Time&lt;/th&gt; &lt;th&gt;In Status&lt;/th&gt; &lt;th&gt;Class Start Time&lt;/th&gt; &lt;/tr&gt;"; while($row = mysql_fetch_array($result)) { echo "&lt;tr&gt;"; echo "&lt;td&gt;" . $row['date'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['intime'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['instatus'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['classstarttime'] . "&lt;/td&gt;"; echo "&lt;/tr&gt;"; } echo "&lt;/table&gt;"; } </code></pre> <p>I have no model</p> <h1> Edit</h1> <pre><code> function query($id){ $sql="SELECT * FROM attendancein WHERE attendeeid = '$id' "; $result = mysql_query($sql); $this-&gt;load-&gt;library('pagination'); $config['base_url'] = base_url().'test/srijon'; $config['total_rows'] = mysql_num_rows($result); $config['per_page'] = '20'; $config['num_links'] = 20; $config['full_tag_open'] = '&lt;div class="pagination" align="center"&gt;'; $config['full_tag_close'] = '&lt;/div&gt;'; $this-&gt;pagination-&gt;initialize($config); $sql="SELECT * FROM attendancein WHERE attendeeid = '$id' LIMIT 20, 5"; $result = mysql_query($sql); echo "&lt;table border='1'&gt; &lt;tr&gt; &lt;th&gt;date&lt;/th&gt; &lt;th&gt;In Time&lt;/th&gt; &lt;th&gt;In Status&lt;/th&gt; &lt;th&gt;Class Start Time&lt;/th&gt; &lt;/tr&gt;"; while($row = mysql_fetch_array($result)) { echo "&lt;tr&gt;"; echo "&lt;td&gt;" . $row['date'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['intime'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['instatus'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['classstarttime'] . "&lt;/td&gt;"; echo "&lt;/tr&gt;"; } echo "&lt;/table&gt;"; echo "&lt;tr&gt;&lt;td&gt;" . $this-&gt;pagination-&gt;create_links() . "&lt;/td&gt;&lt;/tr&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