Results 1 to 22 of 22

Thread: GET issue

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2004
    Posts
    144

    GET issue

    Hey all i'm having an issue with my GET method

    i have one web form with a dropdown box with a list of Degree Schemes that are added to the drop down box using data from a MySQL database, this works fine.

    When a user selects a Degree Scheme from the listbox and clicks the button the user will be directed to the studentDegree.PHP webpage where the result will display, but for some reason the GET method is not getting the information and not passing it in to the WHERE clause can anyone see my problem.

    There is no error being reported, but it displays 'There are 0 student(s) studying this Degree'. I know each degree in the drop down box should have atleast 1 student associated with them!

    Main
    Code:
    <?
    // script to display all the degrees
    
    // connection information
    $hostName = "localhost";
    $userName = "root";
    $password = "12345";
    $dbName = "SOC_DBtest";
    
    // make connection to database
    mysql_connect($hostName, $userName, $password) or die("Unable to connect to host $hostName");
    
    mysql_select_db($dbName) or die("Unable to select database $dbName"); 
    
    // Select all the fields in all the records of the Employees table
    $query = "SELECT *
              FROM tbl_degree";
    
    $result = mysql_query($query);
    
    // Determine the number of employees
    $number = mysql_num_rows($result);
    
    // Create drop-down menu of employee names 
    
    print "View students enroled on a specified degree scheme:<p>
        <form action=\"StudentDegree.php\" method=\"get\">
        <select name=\"DegreeID\">
        <option value=\"\">Select a Degree</option>";
    
    for ($i=0; $i<$number; $i++) {
         $DegreeId  = mysql_result($result,$i,"DegreeId");
         $Degree_Name = mysql_result($result,$i,"Degree_Name");
         print "<option value=\"$DegreeId\">$Degree_Name</option>";
    }
    
    print "</select><input type=\"submit\" value=\"submit\"
        name=\"submit\"></form>";
    
    // Close the database connection
    mysql_close();
    ?>
    StudentDegree
    Code:
    <?
    // script to display who has which computers
    
    // connection information
    $hostName = "localhost";
    $userName = "root";
    $password = "12345";
    $dbName = "SOC_DBtest";
    
    
    // make connection to database
    mysql_connect($hostName, $userName, $password) or die("Unable to connect to host $hostName");
    
    mysql_select_db($dbName) or die( "Unable to select database $dbName".mysql_error()); 
    
    
    // Select the fields from the appropriate tables
    $query =
    
    
    "SELECT tbl_student.Student_Id, tbl_student.Student_FName, tbl_student.Student_SName, tbl_degree.Degree_Name 
    FROM tbl_degree INNER JOIN tbl_student ON tbl_degree.Degree_Id = tbl_student.Degree_Id
    WHERE ((tbl_student.Degree_Id = {get'DegreeID'}))"; 
    
    
    $result = mysql_query($query);
    
    // Determine the number of records returned
    $number = mysql_num_rows($result);
    
    
    // Print the relevant information
    
    print "There are $number student(s) studying this Degree:<p>";
    
    for($i=0; $i<$number; $i++) {
         $studentId = mysql_result($result, $i, "student_Id");
         $stud_FName = mysql_result($result, $i, "Student_FName");
         $stud_SName = mysql_result($result,$i,"Student_SName");
         $stud_Degree = mysql_result($result,$i,"Degree_Name");
         print "$studentId - $stud_FName $stud_SName - $stud_Degree<br>";
    }
    
    // Close the database connection
    mysql_close();
    ?>
    thanks
    Last edited by JamesBowtell; Mar 7th, 2006 at 09:09 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width