Tutorials
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOtherTutorials

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old August 29th, 2003, 03:43 PM
trippleweb trippleweb is offline
Contributing User
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: V
Posts: 702 trippleweb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 33 m 26 sec
Reputation Power: 3
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";
?>

Reply With Quote
  #2  
Old August 29th, 2003, 05:05 PM
trippleweb trippleweb is offline
Contributing User
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: V
Posts: 702 trippleweb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 33 m 26 sec
Reputation Power: 3
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";
?>



Reply With Quote
  #3  
Old August 31st, 2003, 11:21 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 25
RE: Next and Previous links


Reply With Quote
Reply

Viewing: Codewalkers ForumsOtherTutorials > Next and Previous links


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek