|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
||||
|
||||
|
Next and Previous links
I have spent some time to solve the following problem, any thoughts?
I have a page that views single rows, and I want to use Matt's Prev and Next Tutorial for the bottom. When I enter the page you will click on editgorge.php?TransactionNo$ It will then send you to the following php file: editgorge.php: -------------------- <?php include("../dogs.php"); $connection = mysql_connect($host, $user, $password) or die ("Couldn't connect to server."); $db = mysql_select_db ($database, $connection) or die ("Couldn't connect to database."); $query="SELECT * FROM gorgeCalls WHERE TransactionNo='$TransactionNo'"; $result = mysql_query($query) or die("Couldn't execute query."); $row = mysql_fetch_array($result,MYSQL_ASSOC); extract($row); Include "editgorge.inc"; ?> editgorge.inc: ------------------- <html> <head><title>Update Client Profile</title> <style type="text/css"> <!-- INPUT { background-color: #cccccc; } --> </style> </head><html> <body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0"> <font face="helvetica,arial"> <center> <table> <tr><td> <img src="../images/dfxonline.gif"></a> </td><td> <form action="updategorge.php" method="post"> <table border=0> <tr valign=top><td> <table border="0" cellspacing="0"> <tr><td align="right"><b>Transaction No.</b></td> <td><input type="text" name="TransactionNo" value="<?php echo $TransactionNo ?>" size="20" maxlength="20" READONLY></td></tr> <tr><td align="right"><b>Login Name</b></td> <td><input type="text" name="logname" value="<?php echo $logname ?>" size="20" ..... ..........etc) ----------------- Now I would like to add Matt's code at the bottom, my problems is I want to link from a certain TransactionNo first. Help please, I am still a php newbie. Also I only want to view one row at a time. Thanks Matt's Prev next code: ------------------------ <?PHP if(!isset($start)) $start = 0; $query = "SELECT * FROM table LIMIT " . $start . ", 10"; //do database connection $result = mysql_query($query); //you should do error checking //display data //this code was wrong, I did not have the second query. Thanks to Plaggy Pig. // need another query to get the total amount of rows in our table $query = "SELECT count(*) as count FROM table"; $result = mysql_query($query); $row = mysql_fetch_array($result); $numrows = $row['count']; if($start > 0) echo "<a href="" . $PHP_SELF . "?start=" . ($start - 10) . "">Previous</a><BR>n"; if($numrows > ($start + 10)) echo "<a href="" . $PHP_SELF . "?start=" . ($start + 10) . "">Next</a><BR>n"; ?> |
|
#2
|
||||
|
||||
|
RE: Next and Previous links
I have updated the code to this and it works but.....
I still need to take care of when someone links on the TransactionNo, that individual row appears first, does this meke sense? <html> <head><title>Update Client Profile</title> <style type="text/css"> <!-- INPUT { background-color: #cccccc; } --> </style> </head><html> <body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0"> <font face="helvetica,arial"> <center> <table> <tr><td> <img src="../images/dfxonline.gif"></a> </td><td> <form action="updategorge.php" method="post"> <table border=0> <?PHP include("../dogs.php"); $connection = mysql_connect($host, $user, $password) or die ("Couldn't connect to server."); $db = mysql_select_db ($database, $connection) or die ("Couldn't connect to database."); if(!isset($start)) $start = 0; $query = "SELECT * FROM gorgeCalls ORDER BY TransactionNo LIMIT " . $start . ", 1"; //do database connection $result = mysql_query($query); //you should do error checking //display data while($myrow = mysql_fetch_array($result)) { echo "<tr valign=top><td> <table border='0' cellspacing='0'> <tr><td align='right'><b>Transaction No.</b></td> <td><input type='text' name='TransactionNo' value='"; echo $myrow["TransactionNo"]; echo "'size='20' maxlength='20' READONLY></td></tr> <tr><td align='right'><b>Login Name</b></td> <td><input type='text' name='logname' value='"; echo $myrow["logname"]; echo "'size='20' maxlength='20' READONLY></td></tr> <tr><td align='right'><b>Date/Time</b></td> <td><input type='text' name='timeStamp' value='"; echo $myrow["timestamp"]; echo "'size='20' maxlength='20' READONLY></td></tr>"; } echo "</table>"; //this code was wrong, I did not have the second query. Thanks to Plaggy Pig. // need another query to get the total amount of rows in our table $query = "SELECT count(*) as count FROM gorgeCalls"; $result = mysql_query($query); $row = mysql_fetch_array($result); $numrows = $row['count']; if($start > 0) echo "<a href="" . $PHP_SELF . "?start=" . ($start - 1) . "">Previous</a><BR>n"; if($numrows > ($start + 1)) echo "<a href="" . $PHP_SELF . "?start=" . ($start + 1) . "">Next</a><BR>n"; ?> |
|
#3
|
|||
|
|||
|
RE: Next and Previous links
|
![]() |
| Viewing: Codewalkers Forums > Other > Tutorials > Next and Previous links |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|