Jump to content

Link to Next page?? Help!!!


cyberangel

Recommended Posts

 

Hi Everybody,

 

being helped every time in this forum, I am sure that I will get good help this time as well.

I have a page that should display certian records from MySQL database. The code that I use for it is:

 

                    <?php

// Connect to the database server

$dbcnx = @mysql_connect("mysql",

"my-user-name", "my-password");

if (!$dbcnx) {

echo( "<P>Unable to connect to the " .

"database server at this time.</P>" );

exit();

}

// Connect to my-database

if (! @mysql_select_db("my-database") ) {

echo( "<P>Unable to locate the URL " .

"database at this time.</P>" );

exit();

}

?>
                                                        <?php

// Request the text of all the URLs

$result = mysql_query(

"SELECT UID, FirstName, LastName, EmailAddr, Date, Comments FROM my-table ORDER BY UID DESC LIMIT 0 , 30");

if (!$result) {

echo("<P>Error performing query: " .

mysql_error() . "</P>");

exit();

}

echo "<table border='0'>";

// Create header row

echo "<tr>";

echo "<td bgcolor=#577095><strong><font color=#FFFFFF face=Courier size=2>Details</font></strong></td>";

echo "</tr>";

while ( $row = mysql_fetch_array($result) ) {

echo "<tr>";

echo "<td bgcolor=#F4FFFD>" 
. "<font color=#0000FF face=Courier size=2>"
. "Date: " . "</font>" 
. "<font face=Courier size=2>"
. $row["Date"] . "</font>" . "<br>"
. "<font color=#0000FF face=Courier size=2>"
. "First Name: " . "</font>"
. "<font face=Courier size=2>"
. $row["FirstName"] . "</font>" . "<br>" 
. "<font color=#0000FF face=Courier size=2>"
. "Last Name: " . "</font>" 
. "<font face=Courier size=2>"
. $row["LastName"] . "</font>" . "<br>" 
. "<font color=#0000FF face=Courier size=2>"
. "Comments: " . "</font>" 
. "<font face=Courier size=2>"
. $row["Comments"] . "</font>" . "<br>"
. "</td>";

echo "</tr>";

}

echo "</table>\n";



?>

 

This works fine, the only problem is that I want to put a Dynamic Link to the next-> and <-previouse page on every page. Because the records are more then 30, and if I remove the LIMIT 0, 30, it becomes a very long page. Can somebody help me on that?

Many Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/87514-link-to-next-page-help/
Share on other sites

include the attached php file in your project

now do the following

<?
$sql ="..."; // your sql statement
$querystring="........"; // the query string you want to fetch via $_GET
$grpsPerPage=6; // number of records to show in a page
$result=mysql_query(getPagingQuery($sql, $grpsPerPage));
$pagingLink=getPagingLink($sql, $grpsPerPage,'',"$querystring");
$numProduct=mysql_num_rows($result);
if($numProduct>0)
{
    while($rs=mysql_fetch_rarray($result))
   {
       //do your coding 
   }
}
?>

 

now place the following codes where you want your paging links

<?
echo $pagingLink;
?>

 

[attachment deleted by admin]

 

Thanks Lovesmith,

 

I am sure that your code is what I need, the only question is that how do I adjust my code(the code that I am using) into your code. I am totally new to MySQL and PHP. I know that it is a stupid question but I tried my best and checked it every way I could.

 

Thanks again and any further help will be greatly appriciated.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.