473,322 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

link two pages using php

i need to links to php pages together but i dont noe how thats my code
for first page
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  5. <head>
  6. <title>Prac 3 Task 4</title>
  7. </head>
  8. <body>
  9. <?php
  10. $conn = odbc_connect("warehouse","IWSDStudent","assign2");
  11. $sql = "SELECT  customerID,firstName, lastName FROM customer ";
  12. $rs = odbc_exec($conn,$sql);
  13. ?>
  14. <table border="1" summary="product Details">
  15. <tr>
  16. <th>customer ID</th>
  17. <th>First Name</th>
  18. <th>Last Name </th>
  19.  
  20.  
  21. </tr>
  22. <?php
  23. while (odbc_fetch_row($rs))
  24. {
  25. $fName = odbc_result($rs,"firstName");
  26. $lName = odbc_result($rs, "lastName");
  27. $cusID = odbc_result($rs,"customerID");
  28. echo "<td> $cusID</td>"
  29. echo "<tr><td> <a href='task10.php'>$fName </a></td>";
  30. echo "<td> $lName</td></tr>";
  31.  
  32. }
  33. odbc_close($conn);
  34. ?>
  35. </table>
  36. </body>
  37. </html>
second page
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  5. <head>
  6. <title>Task 10 PHP</title>
  7. </head>
  8. <body>
  9. <table border="1" summary="product Details">
  10. <tr>
  11. <th>Order NO</th>
  12. <th>Order date </th>
  13. <th>Shipped</th>
  14. </tr> 
  15. <?php 
  16. $cusID = $_GET["custID"];
  17. $conn = odbc_connect("warehouse","IWSDStudent","assign2");
  18. $sql= "SELECT orderNumber, orderDate,shipped FROM orders WHERE customerID= '$cusID'";
  19. $rs = odbc_exec($conn,$sql);
  20. if ($rs) { // Got some data?
  21. while (odbc_fetch_row($rs))
  22. {
  23. $orderNo = odbc_result($rs,"orderNumber");
  24. $orderdate = odbc_result($rs, "orderDate");
  25. $shipped = odbc_result($rs,"shipped");
  26. echo "<tr><td>$orderNo</td>";
  27. echo "<td> $orderdate</td>";
  28. echo "<td> $shipped</td></tr>";
  29.  
  30. }
  31.  
  32.       }
  33.  
  34.       else {
  35.  
  36.     // Display an error message if no data was retrieved or some other error condition was encountered.
  37.  
  38.     print "<p>There's no values for the customer id please try again: $cusID.</p>";
  39.     print "<p><a href=\"task10.htm\">Return to try another number.</a></p>";
  40.  
  41.   }
  42.   odbc_close($conn);
  43. ?>
  44.  
  45.  
  46. </body>
  47. </html>
plz help
thanks
May 12 '09 #1
6 9035
Ciary
247 Expert 100+
what do you mean by linking them together?

btw use code tags, it makes things so much easier to read :)

EDIT nvm, i think i know what you mean by linking them. if you want to send $_GET[] variable, you need to put the variable in your url.
Expand|Select|Wrap|Line Numbers
  1. http://www.my-domain.org/my-page.php?myFirstVariable=aValue&mySecondVariable=2
  2.  
then, you can get the variables with $_GET
example:
Expand|Select|Wrap|Line Numbers
  1. echo $_GET['myFirstVariable'];
  2. echo $_GET['mySecondVariable'];
this will result in

aValue2
May 12 '09 #2
prabirchoudhury
162 100+
Get Customer page

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
  4. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
  5. <head> 
  6. <title>Prac 3 Task 4</title> 
  7. </head> 
  8. <body> 
  9. <?php 
  10. $conn = odbc_connect("warehouse","IWSDStudent","assign2"); 
  11. $sql = "SELECT  customerID,firstName, lastName FROM customer "; 
  12. $rs = odbc_exec($conn,$sql); 
  13. ?> 
  14. <table border="1" summary="product Details"> 
  15. <tr> 
  16. <th>customer ID</th> 
  17. <th>First Name</th> 
  18. <th>Last Name </th> 
  19.  
  20.  
  21. </tr> 
  22. <?php 
  23. while (odbc_fetch_row($rs)) 
  24. $fName = odbc_result($rs,"firstName"); 
  25. $lName = odbc_result($rs, "lastName"); 
  26. $custID = odbc_result($rs,"customerID"); 
  27. // pass the $cistID as a query string variable to the task10 page 
  28. echo "<td> <a href='task10.php?custID=$custID'>$cusID<a></td>" 
  29. echo "<tr><td> <a href='task10.php?custID=$custID'>$fName </a></td>"; 
  30. echo "<td><a href='task10.php?custID=$custID'> $lName</a></td></tr>";   
  31. odbc_close($conn); 
  32. ?> 
  33. </table> 
  34. </body> 
  35. </html> 
page task10

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
  4. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
  5. <head> 
  6. <title>Task 10 PHP</title> 
  7. </head> 
  8. <body> 
  9. <table border="1" summary="product Details"> 
  10. <tr> 
  11. <th>Order NO</th> 
  12. <th>Order date </th> 
  13. <th>Shipped</th> 
  14. </tr>  
  15. <?php  
  16. if (isset($_GET['custID'])){ 
  17. $custID = $_GET["custID"]; 
  18. }
  19. $conn = odbc_connect("warehouse","IWSDStudent","assign2"); 
  20. $sql= "SELECT orderNumber, orderDate,shipped FROM orders WHERE customerID= '$custID'"; 
  21. $rs = odbc_exec($conn,$sql); 
  22. if ($rs) { // Got some data? 
  23. while (odbc_fetch_row($rs)) 
  24. $orderNo = odbc_result($rs,"orderNumber"); 
  25. $orderdate = odbc_result($rs, "orderDate"); 
  26. $shipped = odbc_result($rs,"shipped"); 
  27. echo "<tr><td>$orderNo</td>"; 
  28. echo "<td> $orderdate</td>"; 
  29. echo "<td> $shipped</td></tr>"; 
  30.  
  31.  
  32.       } 
  33.  
  34.       else { 
  35.  
  36.     // Display an error message if no data was retrieved or some other error condition was encountered. 
  37.  
  38.     print "<p>There's no values for the customer id please try again: $cusID.</p>"; 
  39.     print "<p><a href=\"task10.htm\">Return to try another number.</a></p>"; 
  40.  
  41.   } 
  42.   odbc_close($conn); 
  43. ?> 
  44.  
  45.  
  46. </body> 
  47. </html> 
read php $_post, $_get and $_request method
May 12 '09 #3
thanks alot for help
May 13 '09 #4
i dont know why doesnt work to check id entered is save in database is just return empty field but i want to say to customer click link below because u entered wrong id
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Task 10 PHP</title>
</head>
<body>
<table border="1" summary="product Details">
<tr>
<th>Order NO</th>
<th>Order date </th>
<th>Shipped</th>
</tr>
<?php
$cusID = $_GET["custID"];
$conn = odbc_connect("warehouse","IWSDStudent","assign2");
$sql= "SELECT orderNumber, orderDate,shipped FROM orders WHERE customerID= '$cusID'";
$rs = odbc_exec($conn,$sql);
if ($rs) { // Got some data?
while (odbc_fetch_row($rs))
{
$orderNo = odbc_result($rs,"orderNumber");
$orderdate = odbc_result($rs, "orderDate");
$shipped = odbc_result($rs,"shipped");
echo "<tr><td>$orderNo</td>";
echo "<td> $orderdate</td>";
echo "<td> $shipped</td></tr>";

}

}

else {

// Display an error message if no data was retrieved or some other error condition was encountered.

print "<p>There's no values for the customer id please try again: $cusID.</p>";
print "<p><a href=\"task10.htm\">Return to try another number.</a></p>";

}
odbc_close($conn);
?>


</body>
</html>
thanks
May 13 '09 #5
prabirchoudhury
162 100+
that’s fine ... glad to help
May 13 '09 #6
and i solve the above problem too
thanks again
May 13 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Craig | last post by:
Hi, What I'm trying (quite poorly) to do is make it so when a link is clicked the text inside a div or p changes. I've tried numerous things, most of which work in IE but none of which work in...
1
by: Unregistered | last post by:
I'm making an Intranet site for someone who is not very familiar wit making websites, thus I would like to make it as simple as possible fo her when she needs to update it. The intranet site...
6
by: Xerxes | last post by:
Hi, how can I activate a login when someone clicks on a link? I want only authorized users to have access to the pages accessible through the links. Thanks.
2
by: Tom Jordan | last post by:
Hi all, Ok, could do with some advice on this. I've written a script in ASP for a client so they can compose HTML newsletters and include various products from the online database. I didn't...
9
by: Yeah | last post by:
I have web document A which contains six links that all go to document B. However, all hyperlinks must go to a different location within that document (similar to anchors: A NAME= etc.). How do...
3
by: Rhino | last post by:
Yesterday, I reworked the index on my site - http://sfl.london.on.ca - so that they used list markup and I'm quite pleased with them. However, I'm having a problem with one small aspect of the menu...
9
by: Richard | last post by:
Please hlep with a very frustrating problem. I need to be able to have a reference to my "btcopyrights" CSS class override the link colors first specified earlier in the CSS. I inherited a large...
3
by: hestres | last post by:
Hello, I'm working on some link styles for this page: http://www.house.gov/velazquez/lh0205tres/reports.html I want all the links to always display in red (#CC0000), but in IE6 and 7 they...
38
by: ted | last post by:
I have an old link that was widely distributed. I would now like to put a link on that old page that will go to a new page without displaying anything.
2
by: Keith G Hicks | last post by:
I'm confused about how to code a link button to go to the page I need (asp.net 2.0) My root is "Website1" Here's the layout for the purposes of this question: Website1 (folder)...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.