link two pages using php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lolodede
    New Member
    • Apr 2009
    • 63

    link two pages using php

    i need to links to php pages together but i dont noe how thats my code
    for first page
    Code:
    <?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>Prac 3 Task 4</title>
    </head>
    <body>
    <?php
    $conn = odbc_connect("warehouse","IWSDStudent","assign2");
    $sql = "SELECT  customerID,firstName, lastName FROM customer ";
    $rs = odbc_exec($conn,$sql);
    ?>
    <table border="1" summary="product Details">
    <tr>
    <th>customer ID</th>
    <th>First Name</th>
    <th>Last Name </th>
    
    
    </tr>
    <?php
    while (odbc_fetch_row($rs))
    {
    $fName = odbc_result($rs,"firstName");
    $lName = odbc_result($rs, "lastName");
    $cusID = odbc_result($rs,"customerID");
    echo "<td> $cusID</td>"
    echo "<tr><td> <a href='task10.php'>$fName </a></td>";
    echo "<td> $lName</td></tr>";
    
    }
    odbc_close($conn);
    ?>
    </table>
    </body>
    </html>
    second page
    Code:
    <?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>
    plz help
    thanks
    Last edited by Markus; May 12 '09, 05:39 PM. Reason: Added [code] tags.
  • Ciary
    Recognized Expert New Member
    • Apr 2009
    • 247

    #2
    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.
    Code:
    http://www.my-domain.org/my-page.php?myFirstVariable=aValue&mySecondVariable=2
    then, you can get the variables with $_GET
    example:
    Code:
    echo $_GET['myFirstVariable'];
    echo $_GET['mySecondVariable'];
    this will result in

    aValue2

    Comment

    • prabirchoudhury
      New Member
      • May 2009
      • 162

      #3
      link two pages using php

      Get Customer page

      Code:
      <?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>Prac 3 Task 4</title> 
      </head> 
      <body> 
      <?php 
      $conn = odbc_connect("warehouse","IWSDStudent","assign2"); 
      $sql = "SELECT  customerID,firstName, lastName FROM customer "; 
      $rs = odbc_exec($conn,$sql); 
      ?> 
      <table border="1" summary="product Details"> 
      <tr> 
      <th>customer ID</th> 
      <th>First Name</th> 
      <th>Last Name </th> 
        
        
      </tr> 
      <?php 
      while (odbc_fetch_row($rs)) 
      { 
      $fName = odbc_result($rs,"firstName"); 
      $lName = odbc_result($rs, "lastName"); 
      $custID = odbc_result($rs,"customerID"); 
      // pass the $cistID as a query string variable to the task10 page 
      echo "<td> <a href='task10.php?custID=$custID'>$cusID<a></td>" 
      echo "<tr><td> <a href='task10.php?custID=$custID'>$fName </a></td>"; 
      echo "<td><a href='task10.php?custID=$custID'> $lName</a></td></tr>";   
      } 
      odbc_close($conn); 
      ?> 
      </table> 
      </body> 
      </html>
      page task10

      Code:
      <?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  
      if (isset($_GET['custID'])){ 
      $custID = $_GET["custID"]; 
      }
      $conn = odbc_connect("warehouse","IWSDStudent","assign2"); 
      $sql= "SELECT orderNumber, orderDate,shipped FROM orders WHERE customerID= '$custID'"; 
      $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>
      read php $_post, $_get and $_request method

      Comment

      • lolodede
        New Member
        • Apr 2009
        • 63

        #4
        thanks alot for help

        Comment

        • lolodede
          New Member
          • Apr 2009
          • 63

          #5
          checking write id entered

          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="produc t Details">
          <tr>
          <th>Order NO</th>
          <th>Order date </th>
          <th>Shipped</th>
          </tr>
          <?php
          $cusID = $_GET["custID"];
          $conn = odbc_connect("w arehouse","IWSD Student","assig n2");
          $sql= "SELECT orderNumber, orderDate,shipp ed 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>$order No</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.h tm\">Return to try another number.</a></p>";

          }
          odbc_close($con n);
          ?>


          </body>
          </html>
          thanks

          Comment

          • prabirchoudhury
            New Member
            • May 2009
            • 162

            #6
            that’s fine ... glad to help

            Comment

            • lolodede
              New Member
              • Apr 2009
              • 63

              #7
              and i solve the above problem too
              thanks again

              Comment

              Working...