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
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]

Link to comment
Share on other sites

 

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.

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.