Pagination - No one seems to know the answer

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Pagination - No one seems to know the answer

Post by mohson »

I have been working on this code for about 2 weeks - I have scoured the web and joined so many forums but no one seems to be able to help - information seems to be conflicting - people are really helpful but im even more confused now then when I started on Opendeveloper.org someone told me in relation to my pagination query that:

"The approach you are trying to use (LIMIT in the SQL) won't do what you want (the database will return the first N items everytime)."

It was so frustrating to find out the approach I was using for two weeks wasnt even the correct approach, im not entirely sure this is correct though. can you guys help - I have been working on this navigation function to navigate my records 10 records at a time below is the related code. Thank you for your patience.

Code: Select all

<?php



/* Connecting, selecting database */
$link = mysql_connect("****", "***", "******")
   or die("Could not connect : " . mysql_error());
echo "";
mysql_select_db("contact_management_system") or die("Could not select database");


    $limit          = 10;               
    $query_count    = "SELECT count(*) FROM people";    
    $result_count   = mysql_query($query_count);    
    $totalrows      = mysql_num_rows($result_count);

    
$page = (!empty($_REQUEST['page'])) ? $_REQUEST['page'] : 1; 

 $limitvalue = $page * $limit - ($limit);
    $query  = "SELECT * FROM people ORDER BY firstname LIMIT $limitvalue,$limit";        
    $result = mysql_query($query) or die("Error: " . mysql_error());

    if(mysql_num_rows($result) == 0){
        echo("Nothing to Display!");
    } 
   

// Begin your table outside of the array
echo "<table width="50%" border="0" cellpadding="2" cellspacing="2">
    <tr>
        <td width="110"><b><small>ID</small></b></td>
        <td><b></b></td>
		<td><b><small>First Name</small></b></td>
		<td><b><small>Surname</small></b></td>
		<td><b><small>Organisation</small></b></td>
		<td><b><center><small>Role</small></center></b></td>
		<td><b><small>Address(1)</small></b></td>
		<td><b><small>Address(2)</small></b></td>
		<td><b><small>City</small></b></td>
		<td><b><small>Post Code</small></b></td>
		<td><b><small>Telephone</small></b></td>
		<td><b><small>Mobile</small></b></td>
		<td><b><small>Fax</small></b></td>
		<td><b><small>Last Contact</small></b></td>
		<td><b><small>Contact Again</small></b></td>
		<td><b><small>Notes</small></b></td>
		
    </tr>"; 
	
// Define your colors for the alternating rows

$color1 = "#ADD8E6";
$color2 = "#E0FFFF";
$row_count = 0; 
	




/* Printing results in HTML */

while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
	$person_id = $line["person_id"];
    $salutation = $line["salutation"];
	$firstname = $line["firstname"];
    $surname = $line["surname"]; 
	$organisation = $line["organisation"];
	$role = $line["role"];
	$address1 = $line["address1"];
	$address2 = $line["address2"];
	$city = $line["city"];
	$postcode = $line["postcode"];
	$telephone = $line["telephone"];
	$mobile = $line["mobile"];
	$fax = $line["fax"];
	$dateoflastcontact = $line["dateoflastcontact"];
	$datecontactagain = $line["datecontactagain"];
	$notes = $line["notes"];
	$email = $line["email"];
	
	
	/* Now we do this small line which is basically going to tell
    PHP to alternate the colors between the two colors we defined above. */

    $row_color = ($row_count % 2) ? $color1 : $color2; 
	
	
	 // Echo your table row and table data that you want to be looped over and over here. 
  
echo "<tr>
    <td width="20" bgcolor="$row_color" 	 nowrap><a href ="Upeople.html">$person_id 
    </td>
    <td bgcolor="$row_color">$salutation </td>
	<td width="110" bgcolor="$row_color" nowrap><a href="mailto: $email">$firstname 
    </td>
	<td width="100" bgcolor="$row_color" nowrap><a href="mailto: $email">$surname 
    </td>
	<td width="100" bgcolor="$row_color" nowrap>$organisation 
    </td>
	<td bgcolor="$row_color">$role</td>
	<td width="100" bgcolor="$row_color" nowrap>$address1
    </td>
	<td width="100" bgcolor="$row_color" nowrap>$address2
    </td>
	<td bgcolor="$row_color">$city</td>
	<td width="110" bgcolor="$row_color" nowrap>$postcode
    </td>
	<td bgcolor="$row_color">$telephone</td>
	<td bgcolor="$row_color">$mobile</td>
	<td bgcolor="$row_color">$fax</td>
	<td width="100" bgcolor="$row_color" nowrap>$dateoflastcontact
    </td>
	<td width="100" bgcolor="$row_color" nowrap>$datecontactagain
    </td>
	<td width="300" bgcolor="$row_color" nowrap>$notes 
    </td>
	
	
	
	</tr>"; 
	
	    // Add 1 to the row count

    $row_count++;
}
 
//break before paging
 echo "<br />";

 // next we need to do the links to other results
 
if ($s>=1) { // bypass PREV link if s is 0
 $prevs=($s-$limit);
 print "&nbsp;<a href="$PHP_SELF?s=$prevs"><<
 Prev 10</a>&nbsp&nbsp;";
 }

// calculate number of pages needing links
 
$pages=intval($numrows/$limit);

// $pages now contains int of pages needed unless there is a remainder from division

 if ($numrows%$limit) {

 // has remainder so add one page
 
$pages++;
 }

// check to see if last page
 
if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {

 // not last page so give NEXT link
 
$news=$s+$limit;

 echo "&nbsp;<a href="$PHP_SELF?s=$news">Next 10 >></a>";
 }

$a = $s + ($limit);
 if ($a > $numrows) { $a = $numrows; }
 $b = $s + 1;
 echo "<p>Showing results $b to $a of $numrows</p>";
    
    mysql_free_result($result);

/* Free resultset */
mysql_free_result($result);

/* Closing connection */
mysql_close($link);



?>
</table>


?>
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Re: Pagination - No one seems to know the answer

Post by timvw »

to start: tell php to show you all the errors etc... in the beginning of your script:

Code: Select all

error_reporting(E_ALL);
mohson wrote:

Code: Select all

$link = mysql_connect("****", "***", "******")
mysql_select_db("contact_management_system") or die("Could not select database");
first you store the resource in $link and then you forget using it.. be consequent.. either use it for the following mysql_ calls or just don't save it ;)

mohson wrote:

Code: Select all

$query_count    = "SELECT count(*) FROM people";    
$result_count   = mysql_query($query_count);
i would write that as:

Code: Select all

$query_count = "SELECT COUNT(*) AS count FROM people";
$result_count = mysql_query($query_count);
$result_row = mysql_fetch_assoc($result_count);
$totalrows = $result_row['count'];

mohson wrote:

Code: Select all

$limitvalue = $page * $limit - ($limit);
i think $limitvalue and $limit are unclear names, imho the following looks much cleaner: (i changed $limitvalue to $offset and $limit to $rows_per_page)

Code: Select all

$offset = ($page - 1) * $rows_per_page;
mohson wrote:

Code: Select all

if ($s>=1) {
Where is $s coming from? i can't find it anywhere.

you probably want:

Code: Select all

if ($page > 1)
{
  $prev = $page - 1;
   echo "&nbsp;<a href="$PHP_SELF?s=$prev"><<Prev {$rows_per_page}</a>&nbsp&nbsp;";
}
mohson wrote:

Code: Select all

// calculate number of pages needing links 
$pages=intval($numrows/$limit);
/ $pages now contains int of pages needed unless there is a remainder from division
 if ($numrows%$limit) {
 // has remainder so add one page
$pages++;
 }
this can be written as:

Code: Select all

$available_pages = ceil($totalrows / $rows_per_page);


and so on........
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

Nicely formatted and concise answer timvw...

Changes in release 4.0.6 of mySQL includes the use of an OFFSET keyword...

Code: Select all

SELECT ... LIMIT row_count OFFSET offset
I find this to be even more readable.
So:
LIMIT 10 OFFSET 0 would return the first 10.
LIMIT 10 OFFSET 10 would return 11-20
and so on.
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

thank you

Post by mohson »

thank you, but I have a few queries:

You suggested I use this:

Code: Select all

$query_count = "SELECT COUNT(*) AS count FROM people";
$result_count = mysql_query($query_count);
$result_row = mysql_fetch_assoc($result_count);
$totalrows = $result_row['count'];
Do I still keep my: $limit at the top of this code (as you suggested $limit would now be $rows_per_page)

Code: Select all

$limit          = 10;               
    $query_count    = "SELECT count(*) FROM people";    
    $result_count   = mysql_query($query_count);    
    $totalrows      = mysql_num_rows($result_count);
You suggested I replace:

Code: Select all

if ($s>=1) {
with

Code: Select all

if ($page > 1)
{

Im assuming I replace all the other

Code: Select all

$s <?php  with

Code: Select all

$page <?php

Do I get rid of all this:

Code: Select all

$prevs=($s-$limit);
 print "&nbsp;<a href="$PHP_SELF?s=$prevs"><<
 Prev 10</a>&nbsp&nbsp;";
 }

Finally im not sure about this section as this code was taken from other code snippets;

Code: Select all

// not last page so give NEXT link


$news=$s+$limit;

 echo "&nbsp;<a href="$PHP_SELF?s=$news">Next 10 >></a>";
 }

$a = $s + ($limit);
 if ($a > $numrows) { $a = $numrows; }
 $b = $s + 1;
 echo "<p>Showing results $b to $a of $numrows</p>";
    
    mysql_free_result($result);
im not sure what the $a and $news is for


I really appreciate your help. thank you for your patience

I took your advice on board and updated the code so now it looks like this but now the page goes blank, I think answering the above questions will help to make this work.

Code: Select all

error_reporting(E_ALL);

/* Connecting, selecting database */
$link = mysql_connect("*******", "******", "*****")
   or die("Could not connect : " . mysql_error());
echo "";
mysql_select_db("contact_management_system") or die("Could not select database");


$rows_per_page = 10;               
$query_count = "SELECT COUNT(*) AS count FROM people";
$result_count = mysql_query($query_count);
$result_row = mysql_fetch_assoc($result_count);
$totalrows = $result_row['count'];
    
$page = (!empty($_REQUEST['page'])) ? $_REQUEST['page'] : 1; 

 $offset = $page * $rows_per_page - ($rows_per_page);
    $query  = "SELECT * FROM people ORDER BY firstname LIMIT $offset,$rows_per_page";        
    $result = mysql_query($query) or die("Error: " . mysql_error());

    if(mysql_num_rows($result) == 0){
        echo("Nothing to Display!");
    } 
   

// Begin your table outside of the array
echo "<table width="50%" border="0" cellpadding="2" cellspacing="2">
    <tr>
        <td width="110"><b><small>ID</small></b></td>
        <td><b></b></td>
		<td><b><small>First Name</small></b></td>
		<td><b><small>Surname</small></b></td>
		<td><b><small>Organisation</small></b></td>
		<td><b><center><small>Role</small></center></b></td>
		<td><b><small>Address(1)</small></b></td>
		<td><b><small>Address(2)</small></b></td>
		<td><b><small>City</small></b></td>
		<td><b><small>Post Code</small></b></td>
		<td><b><small>Telephone</small></b></td>
		<td><b><small>Mobile</small></b></td>
		<td><b><small>Fax</small></b></td>
		<td><b><small>Last Contact</small></b></td>
		<td><b><small>Contact Again</small></b></td>
		<td><b><small>Notes</small></b></td>
		
    </tr>"; 
	
// Define your colors for the alternating rows

$color1 = "#ADD8E6";
$color2 = "#E0FFFF";
$row_count = 0; 
	




/* Printing results in HTML */

while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
	$person_id = $line["person_id"];
    $salutation = $line["salutation"];
	$firstname = $line["firstname"];
    $surname = $line["surname"]; 
	$organisation = $line["organisation"];
	$role = $line["role"];
	$address1 = $line["address1"];
	$address2 = $line["address2"];
	$city = $line["city"];
	$postcode = $line["postcode"];
	$telephone = $line["telephone"];
	$mobile = $line["mobile"];
	$fax = $line["fax"];
	$dateoflastcontact = $line["dateoflastcontact"];
	$datecontactagain = $line["datecontactagain"];
	$notes = $line["notes"];
	$email = $line["email"];
	
	
	/* Now we do this small line which is basically going to tell
    PHP to alternate the colors between the two colors we defined above. */

    $row_color = ($row_count % 2) ? $color1 : $color2; 
	
	
	 // Echo your table row and table data that you want to be looped over and over here. 
  
echo "<tr>
    <td width="20" bgcolor="$row_color" 	 nowrap><a href ="Upeople.html">$person_id 
    </td>
    <td bgcolor="$row_color">$salutation </td>
	<td width="110" bgcolor="$row_color" nowrap><a href="mailto: $email">$firstname 
    </td>
	<td width="100" bgcolor="$row_color" nowrap><a href="mailto: $email">$surname 
    </td>
	<td width="100" bgcolor="$row_color" nowrap>$organisation 
    </td>
	<td bgcolor="$row_color">$role</td>
	<td width="100" bgcolor="$row_color" nowrap>$address1
    </td>
	<td width="100" bgcolor="$row_color" nowrap>$address2
    </td>
	<td bgcolor="$row_color">$city</td>
	<td width="110" bgcolor="$row_color" nowrap>$postcode
    </td>
	<td bgcolor="$row_color">$telephone</td>
	<td bgcolor="$row_color">$mobile</td>
	<td bgcolor="$row_color">$fax</td>
	<td width="100" bgcolor="$row_color" nowrap>$dateoflastcontact
    </td>
	<td width="100" bgcolor="$row_color" nowrap>$datecontactagain
    </td>
	<td width="300" bgcolor="$row_color" nowrap>$notes 
    </td>
	
	
	
	</tr>"; 
	
	    // Add 1 to the row count

    $row_count++;
}
 
//break before paging
 echo "<br />";

 // next we need to do the links to other results
 

 if ($page > 1)
{
$prev = $page - 1;
   echo "&nbsp;<a href="$PHP_SELF?s=$prev"><<Prev {$rows_per_page}</a>&nbsp&nbsp;";
} // bypass PREV link if s is 0
 
$prevs=($page-$rows_per_page);
 print "&nbsp;<a href="$PHP_SELF?s=$prevs"><<
 Prev 10</a>&nbsp&nbsp;";
 }

// calculate number of pages needing links 

$available_pages = ceil($totalrows / $rows_per_page);

// check to see if last page
 
if (!((($page+$rows_per_page)/$rows_per_page)==$pages) && $pages!=1) {

 // not last page so give NEXT link
 
$news=$page+$rows_per_page;

 echo "&nbsp;<a href="$PHP_SELF?s=$news">Next 10 >></a>";
 }

$a = $page + ($rows_per_page);
 if ($a > $numrows) { $a = $numrows; }
 $b = $page + 1;
 echo "<p>Showing results $b to $a of $numrows</p>";
    
    mysql_free_result($result);

/* Free resultset */
mysql_free_result($result);

/* Closing connection */
mysql_close($link);



?>
</table>
Last edited by mohson on Mon Dec 13, 2004 10:50 am, edited 1 time in total.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Re: thank you

Post by timvw »

mohson wrote:

Code: Select all

while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {

	$person_id = $line["person_id"];
    $salutation = $line["salutation"];
	$firstname = $line["firstname"];
    $surname = $line["surname"]; 
	$organisation = $line["organisation"];
	$role = $line["role"];
	$address1 = $line["address1"];

        .......
instead of writing all those assignments, use [php_man]extract[/php_man]

Code: Select all

extract($line);

mohson wrote:

Code: Select all

if ($page > 1)
{
$prev = $page - 1;
   echo "&nbsp;<a href="$PHP_SELF?s=$prev"><<Prev {$rows_per_page}</a>&nbsp&nbsp;";
} // bypass PREV link if s is 0
i think you don't have a clue what is happening here. probably it's best you tell us first what you are trying to do, and then we can tell you what is going wrong... because otherway we'll end up feeling that we are doing your homework....

the most simple pagination bar would look like:

Code: Select all

$lastpage = ceil($totalrows / $rows_per_page);

if ($page == 1) {
   echo " FIRST PREV ";
} else {
   echo " <a href='{$_SERVER['PHP_SELF']}?page=1'>FIRST</a> ";
   $prevpage = $page-1;
   echo " <a href='{$_SERVER['PHP_SELF']}?page=$prevpage'>PREV</a> ";
} // if

echo " ( Page $page of $lastpage ) ";

if ($page == $lastpage) {
   echo " NEXT LAST ";
} else {
   $nextpage = $page+1;
   echo " <a href='{$_SERVER['PHP_SELF']}?page=$nextpage'>NEXT</a> ";
   echo " <a href='{$_SERVER['PHP_SELF']}?page=$lastpage'>LAST</a> ";
} // if
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Post by mohson »

Ok,

I am devloping a Contacts Management System what im trying to do is display 10 records at a time.

Its weird but its seems simple I want to display 10 records on the initial page and then let the users select next to go to the next 10 records and so on - aswell as indicating which record they are on as in 1 to 10 of 100 or 11 to 21 of 100, thats it really :?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

well, you're almost there....

here is the thingie i built this weekend: (it has pagination - ordering - ...)
http://home.mysth.be/~timvw/demo/index.php

login with username: timvw password: password

and edit a sale or whatever ;)
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Post by mohson »

thak you tim thats exactly what I want to do - any chance of any help?? im strugling real bad
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Post by mohson »

Tim,

Someone has just informed me that the easiest way to do paging is through mysql - not sure but do you know anything about this??
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

well, that is what my code is doing :P

pagination is about:

1-)
determine how many rows there are ($available_rows)
determine how many rows you want to show on a page ($rows_per_page)
calculate how many pages there are (ceil($available_rows / $rows_per_page))

2-)
determine which page is requested (and check if that page is in range)

3-)
determine which rows would be shown in thage page( from (($page - 1) * $rows_per_page) to ($page * $rows_per_page)).with mysql you probably retrieve the rows using the LIMIT clause

ready.

another source of info http://www.tonymarston.net/php-mysql/pagination.html
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Post by mohson »

yeh but Tim I cant see your code??
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Post by mohson »

Tim,

Thanks for the tutorial

http://www.tonymarston.net/php-mysql/pagination.html

looks excellent and I used it but... when i incorporated it into my code the page just went blank - can you see any errors I have missed Tim - I really appreciate your patience.

Im new to this but I cant see any errors can you spot anything??

Code: Select all

/* Connecting, selecting database */
$link = mysql_connect("******", "*****", "*******")
   or die("Could not connect : " . mysql_error());
echo "";
mysql_select_db("contact_management_system") or die("Could not select database");

//* This code will obtain the required page number from the $_GET array. Note that if it is not present it will default to 1.
  
if (isset($_GET['pageno'])) {
   $pageno = $_GET['pageno'];
} else {
   $pageno = 1;
} // if

//* This code will count how many rows will satisfy the current query.

$query = "SELECT count(*) FROM people ORDER BY firstname";
$result = mysql_query($query, $db) or trigger_error("SQL", E_USER_ERROR);
$query_data = mysql_fetch_row($result);
$numrows = $query_data[0];

//*This code uses the values in $rows_per_page and $numrows in order to identify the number of the last page.

$rows_per_page = 10;
$lastpage      = ceil($numrows/$rows_per_page);

//*This code checks that the value of $pageno is an integer between 1 and $lastpage

$pageno = (int)$pageno;
if ($pageno < 1) {
   $pageno = 1;
} elseif ($pageno > $lastpage) {
   $pageno = $lastpage;
} // if

//*This code will construct the LIMIT clause for the sql SELECT statement.

$limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page;

//*Now we can issue the database query and process the result.

$query = "SELECT * FROM people $limit";
$result = mysql_query($query, $db) or trigger_error("SQL", E_USER_ERROR);
... process contents of $result ...

//*Finally we must construct the hyperlinks which will allow the user to select other pages. 
We will start with the links for any previous pages.

if ($pageno == 1) {
   echo " FIRST PREV ";
} else {
   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=1'>FIRST</a> ";
   $prevpage = $pageno-1;
   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage'>PREV</a> ";
} // if

//*Next we inform the user of his current position in the sequence of available pages.

echo " ( Page $pageno of $lastpage ) ";

//*This code will provide the links for any following pages.

if ($pageno == $lastpage) {
   echo " NEXT LAST ";
} else {
   $nextpage = $pageno+1;
   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'>NEXT</a> ";
   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$lastpage'>LAST</a> ";
} // if


// Begin your table outside of the array
echo "<table width="50%" border="0" cellpadding="2" cellspacing="2">
    <tr>
        <td width="110"><b><small>ID</small></b></td>
        <td><b></b></td>
		<td><b><small>First Name</small></b></td>
		<td><b><small>Surname</small></b></td>
		<td><b><small>Organisation</small></b></td>
		<td><b><center><small>Role</small></center></b></td>
		<td><b><small>Address(1)</small></b></td>
		<td><b><small>Address(2)</small></b></td>
		<td><b><small>City</small></b></td>
		<td><b><small>Post Code</small></b></td>
		<td><b><small>Telephone</small></b></td>
		<td><b><small>Mobile</small></b></td>
		<td><b><small>Fax</small></b></td>
		<td><b><small>Last Contact</small></b></td>
		<td><b><small>Contact Again</small></b></td>
		<td><b><small>Notes</small></b></td>
		
    </tr>"; 
	
// Define your colors for the alternating rows

$color1 = "#ADD8E6";
$color2 = "#E0FFFF";
$row_count = 0; 
	


/* Printing results in HTML */

while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
	$person_id = $line["person_id"];
    	$salutation = $line["salutation"];
	$firstname = $line["firstname"];
   	 $surname = $line["surname"]; 
	$organisation = $line["organisation"];
	$role = $line["role"];
	$address1 = $line["address1"];
	$address2 = $line["address2"];
	$city = $line["city"];
	$postcode = $line["postcode"];
	$telephone = $line["telephone"];
	$mobile = $line["mobile"];
	$fax = $line["fax"];
	$dateoflastcontact = $line["dateoflastcontact"];
	$datecontactagain = $line["datecontactagain"];
	$notes = $line["notes"];
	$email = $line["email"];
	
	
	//* Now we do this small line which is basically going to tell
    PHP to alternate the colors between the two colors we defined above. */

    $row_color = ($row_count % 2) ? $color1 : $color2; 
	
	
	 // Echo your table row and table data that you want to be looped over and over here. 
  
echo "<tr>
    <td width="20" bgcolor="$row_color" 	 nowrap><a href ="Upeople.html">$person_id 
    </td>
    <td bgcolor="$row_color">$salutation </td>
	<td width="110" bgcolor="$row_color" nowrap><a href="mailto: $email">$firstname 
    </td>
	<td width="100" bgcolor="$row_color" nowrap><a href="mailto: $email">$surname 
    </td>
	<td width="100" bgcolor="$row_color" nowrap>$organisation 
    </td>
	<td bgcolor="$row_color">$role</td>
	<td width="100" bgcolor="$row_color" nowrap>$address1
    </td>
	<td width="100" bgcolor="$row_color" nowrap>$address2
    </td>
	<td bgcolor="$row_color">$city</td>
	<td width="110" bgcolor="$row_color" nowrap>$postcode
    </td>
	<td bgcolor="$row_color">$telephone</td>
	<td bgcolor="$row_color">$mobile</td>
	<td bgcolor="$row_color">$fax</td>
	<td width="100" bgcolor="$row_color" nowrap>$dateoflastcontact
    </td>
	<td width="100" bgcolor="$row_color" nowrap>$datecontactagain
    </td>
	<td width="300" bgcolor="$row_color" nowrap>$notes 
    </td>
	
	
	
	</tr>"; 
	
	    // Add 1 to the row count

    $row_count++;
}
 


/* Free resultset */
mysql_free_result($result);

/* Closing connection */
mysql_close($link);

?>
</table>
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

if you still don't have a clue about what you're doing (or should do) i'm affraid i give up.
npeelman
Forum Commoner
Posts: 32
Joined: Tue Jul 27, 2004 5:13 am
Location: Oviedo,FL.

Pagination...

Post by npeelman »

Have you got this figured out yet... I might be able to help...

Norm
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Post by mohson »

thanks alot thats sorted and its brilliant but there a re a few other things that Ive posted on here which no one seems to be able to help with: search forums by author for my name: mohson - all of the older dated stuff I have sorted but some of the more recent posts still need answers would really appreciate it. Is there any chance I could send you private emails if I get stuck with anything??

I really appreciate your willingness to help with my original post

Cheers
Post Reply