Jump to content

Using free pagination script


emilcarlo

Recommended Posts

Good morning,

 

First, I want to thank this forum for all the help provided to me. I am new to Php programming, and honestly, I am still not good at reading codes. I am somehow able to understand how the code is written, but I am still learning, and I know myself, I still have lots to learn. I was able to finish now my very php project, again, thanks to this site and to other forum sites I have visited, and for my friends who helped as well. The web application I made is working fine now, but as I look into it, I know that once the database is populated with information, I will be required to put up pagination on my search page. And so, I looked online for pagination tutorials. I have found some, but I have to admit, it is still hard for me to comprehend the scripts I found. Just today, I found a script that I think would be a very good implementation to the web application I made. The problem is, I am not well familiar with adopting pre-made codes to the one I did, plus the fact that I can't well understand how the code is written. Can anyone help me implement the code, and somehow provide comments on the pre-made code I found in the web? Thank you in advanced for your responses.

 

Here's my code:

 

<link href="add_client.css" rel="stylesheet" type="text/css">

<?PHP
include("dbconnection.php");



$query = "SELECT * FROM records";
$result = array();

if(isset($_POST["btnSearch"]))

{
	$query .= " WHERE last_name LIKE '%".$_POST["search"]."%' OR first_name LIKE '%".$_POST["search"]."%'OR territory LIKE '%".$_POST["search"]."%'OR job_title LIKE '%".$_POST["search"]."%'OR title LIKE '%".$_POST["search"]."%'OR employer LIKE '%".$_POST["search"]."%' ORDER BY territory ASC"  ;

$result = mysql_query($query, $connection) or die(mysql_error());

} 

?>

<table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><table width="760" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="199" align="center" valign="top"><a href="login.html"><img src="invent-asia.gif" alt="" width="152" height="58" border="0" /></a>        <script type="text/javascript" src="menu.js"></script></td>
        <td width="176" align="right" valign="bottom"><a href="main.php"><img src="Home.jpg" width="104" height="20" border="0"/></a></td>
        <td width="130" align="right" valign="bottom"><img src="View.jpg" width="104" height="20" border="0"/></td>
        <td width="146" align="right" valign="bottom"><a href="add_client.php"><img src="Add.jpg" width="104" height="20" border="0"/></a></td>
        <td width="109" align="right" valign="bottom"> </td>
        </tr>

    </table></td>
  </tr>
  <tr>
    <td><table width="760" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="200" height="3"  bgcolor="#1B1C78"><img src="images/topspacerblue.gif" alt="" width="1" height="3" /></td>
        <td width="560"  bgcolor="#0076CC"><img src="images/topspacerlblue.gif" alt="" width="1" height="3" /></td>

      </tr>
    </table></td>

  </tr>
  <tr>
    <td height="553" align="center" valign="top" bgcolor="#F3FAFE"><br />

      <form name="form" action="view_client.php" method="post">
        <br />
      <table width="351" border="0">
          <tr>
            <td width="137" align="left" valign="middle">SEARCH RECORD:</td>
            <td width="144" align="center" valign="middle"><input type="text" name="search" /></td>
            <td width="56" align="left" valign="middle"><input type="submit" name="btnSearch" value="Search" /></td>
          </tr>
        </table>
        <br />
        <table border="0" cellpadding="3" cellspacing="1" bordercolor="38619E" >
          <tr>
            <th width="80" align="center" bgcolor="#E0E8F3">Territory</th>
            <th width="330" align="center" bgcolor="#E0E8F3">Employer</th>
             <th width="160" align="center" bgcolor="#E0E8F3">Name</th>
            <th width="80" align="center" valign="middle" bgcolor="#E0E8F3"> </th>
          </tr>
  <?php
  if($result)
  {
  for($i=0; $i<mysql_num_rows($result); $i++)
  {
	  $id = trim(mysql_result($result, $i, "id"));
	  $territory = trim(mysql_result($result, $i, "territory"));
	  $employer = trim(mysql_result($result, $i, "employer"));
	  $first_name = trim(mysql_result($result, $i, "first_name"));
	  $last_name = trim(mysql_result($result, $i, "last_name"));
			  
	  echo "<tr>";
  		  echo "<td>".$territory."</td>";
	  echo "<td>".$employer."</td>";
	  echo "<td>".$last_name.", ".$first_name."</td>";
	  echo "<td><a href='edit_client.php?id=".$id."'>edit</a> | <a href='delete_client.php?id=".$id."'>delete</a> </td>";
	  echo "</tr>";
  }
  }
  
  ?>
  
        </table>
        <p><br />
        </p>
      </form>
    <p> </p></td>

  </tr>
  <tr>
    <td height="38"><table width="760" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="200" height="35" align="center"  bgcolor="#1B1C78" class=white><img src="images/topspacerblue.gif" alt="" width="1" height="3" /> <a href="disclaimer.html"><font color="#FFFFFF">Legal Disclaimer</font></a> </td>

        <td width="560" align="center"  bgcolor="#0076CC"  class=white><img src="images/topspacerlblue.gif" alt="" width="1" height="3" /> Copyright © 2006 - 2010 InventAsia Limited. All rights reserved.
</td>
      </tr>

    </table></td>
  </tr>
</table>

 

And here is the link of the pagination script I found:

 

http://www.phpeasycode.com/pagination/

 

I'd rather have the pagination style of the first one.

 

Note:

 

I am not trying to be spoon fed here, but really in this case, I have tried what I think should work, but :( Sorry guys.

 

(The way my code is written, you should see that I am a noob xD)

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.