| | |
PHP Paging Problem :(
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
This is a page name search.php
and I post value a to another page name demo_paging1.php
when I put Query
html Syntax (Toggle Plain Text)
<form action="/ap/demo_paging1.php" method="post"> <input type="text" value="Enter Site ID" name="a" class="textfield_effect" maxlength="30" onfocus="this.value=''"> <input type="submit" value="Search ID " /> </form>
and I post value a to another page name demo_paging1.php
when I put Query
WHERE SiteId REGEXP '$a' It does not show me the desire result php Syntax (Toggle Plain Text)
<? require "config.php"; // All database details will be included here $page_name="demo_paging1.php"; // If you use this code with a different page ( or file ) name then change this $a= $_POST["a"]; $start=$_GET['start']; if(strlen($start) > 0 and !is_numeric($start)){ echo "Data Error"; exit; } $eu = ($start - 0); $limit = 10; // No of records to be shown per page. $this1 = $eu + $limit; $back = $eu - $limit; $next = $eu + $limit; /////////////// WE have to find out the number of records in our table. We will use this to break the pages/////// $query2=" SELECT * FROM leaseentry WHERE SiteId REGEXP '$a'"; $result2=mysql_query($query2); echo mysql_error(); $nume=mysql_num_rows($result2); /////// The variable nume above will store the total number of records in the table//// /////////// Now let us print the table headers //////////////// $bgcolor="#f1f1f1"; echo "<TABLE width=100% align=center cellpadding=0 cellspacing=0> <tr>"; echo "<td bgcolor='dfdfdf' > <font face='arial,verdana,helvetica' color='#000000' size='4'>Site ID</font></td>"; echo "<td bgcolor='dfdfdf' > <font face='arial,verdana,helvetica' color='#000000' size='4'>Code</font></td>"; echo "<td bgcolor='dfdfdf'> <font face='arial,verdana,helvetica' color='#000000' size='4'>Owner Name</font></td>"; echo "<td bgcolor='dfdfdf'> <font face='arial,verdana,helvetica' color='#000000' size='4'>Lease Agreement</font></td>"; echo "<td bgcolor='dfdfdf'> <font face='arial,verdana,helvetica' color='#000000' size='4'>LA Start Date</font></td>"; echo "<td bgcolor='dfdfdf'> <font face='arial,verdana,helvetica' color='#000000' size='4'>LA END Date</font></td>"; echo "<td bgcolor='dfdfdf'> <font face='arial,verdana,helvetica' color='#000000' size='4'>PO</font></td> </tr>"; ////////////// Now let us start executing the query with variables $eu and $limit set at the top of the page/////////// $query=" SELECT * FROM leaseentry limit $eu, $limit "; $result=mysql_query($query); echo mysql_error(); //////////////// Now we will display the returned records in side the rows of the table///////// while($noticia = mysql_fetch_array($result)) { if($bgcolor=='#f1f1f1'){$bgcolor='#ffffff';} else{$bgcolor='#f1f1f1';} echo "<tr >"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='1'>$noticia[0]</font></td>"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='1'>$noticia[1]</font></td>"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='1'>$noticia[2]</font></td>"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='1'><a href=".$noticia['LA'].">".$noticia['ch']."</a></font></td>"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='1'>".date("j-F-Y",strtotime($noticia['LAPeriodStart']))."</a></font></td>"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='1'>".date("j-F-Y",strtotime($noticia['LAPeriodEnd']))."</a></font></td>"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='1'><a href=".$noticia['PO'].">".$noticia['ch']."</a></font></td>"; echo "</tr>"; } echo "</table>"; ////////////////////////////// End of displaying the table with records //////////////////////// /////////////////////////////// if($nume > $limit ){ // Let us display bottom links if sufficient records are there for paging /////////////// Start the bottom links with Prev and next link with page numbers ///////////////// echo "<table align = 'center' width='50%'><tr><td align='left' width='30%'>"; //// if our variable $back is equal to 0 or more then only we will display the link to move back //////// if($back >=0) { print "<a href='$page_name?start=$back'><font face='Verdana' size='2'>PREV</font></a>"; } //////////////// Let us display the page links at center. We will not display the current page as a link /////////// echo "</td><td align=center width='30%'>"; $i=0; $l=1; for($i=0;$i < $nume;$i=$i+$limit){ if($i <> $eu){ echo " <a href='$page_name?start=$i'><font face='Verdana' size='2'>$l</font></a> "; } else { echo "<font face='Verdana' size='4' color=red>$l</font>";} /// Current page is not displayed as link and given font color red $l=$l+1; } echo "</td><td align='right' width='30%'>"; ///////////// If we are not in the last page then Next link will be displayed. Here we check that ///// if($this1 < $nume) { print "<a href='$page_name?start=$next'><font face='Verdana' size='2'>NEXT</font></a>";} echo "</td></tr></table>"; }// end of if checking sufficient records are there to display bottom navigational link. ?>
Ayesha
WHERE SiteId REGEXP '$a' I use the above quert in both Sql Queries.When I press search it shows first 10 records which are desire, but on page 2 or any other page except page 1 it shows following error related to $a
•
•
•
•
Got error 'empty (sub)expression' from regexp
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\ap\demo_paging1.php on line 37
Site ID Code Owner Name Lease Agreement LA Start Date LA END Date PO
Got error 'empty (sub)expression' from regexp
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\ap\demo_paging1.php on line 62
Ayesha
•
•
Join Date: Apr 2009
Posts: 257
Reputation:
Solved Threads: 37
http://phpsense.com/php/php-pagination-script.html
may be this could help you
may be this could help you
![]() |
Similar Threads
- PHP Paging and Page Number Nav (PHP)
- PHP MYSQL Paging Problem (PHP)
- Paging Problem (PHP)
- php and mod_rewrite problem (PHP)
- serious problem..in online examination ..plz solve that as soon as possible (JavaScript / DHTML / AJAX)
- php mysql problem (PHP)
- PHP + MySQL Problem (PHP)
Other Threads in the PHP Forum
- Previous Thread: Proportional image
- Next Thread: Inputing checkboxes into a MySQL database
| Thread Tools | Search this Thread |
.htaccess ajax apache api array beginner binary broken buttons cakephp checkbox class cms code cron curl database date directory display dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail mediawiki menu mlm mod_rewrite multiple mysql number oop paypal pdf php phpincludeissue phpmyadmin problem query radio random recursion regex remote script search server sessions sms soap source sp space speed sql subdomain syntax system table tag tutorial update upload url validation validator variable vbulletin video web webdesign websphere white xml youtube





