SitePoint Sponsor

User Tag List

Results 1 to 19 of 19

Thread: drop down menu

  1. #1
    SitePoint Zealot Fizlar's Avatar
    Join Date
    Aug 2003
    Location
    Sheffield
    Posts
    179
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    drop down menu

    hi i got this drop down menu where users can choose the course they want however, the value is not passing?? i keep pressing subit yet nothing happens

    can someone tell me whats wrong

    PHP Code:
    <?
    if (!$_REQUEST['Submit']) { 
           
    html_form(); 
    } else { 
         
    select_course(); 



    function 
    my_conn() { 
    $server "***";  
    $username "***";  
    $password "****"

    $link mysql_connect ($server$username$password
    or die (
    "Could not connect"); 

    if (!@
    mysql_select_db("fizlar2"$link)) {    
         echo 
    "<p>There has been an error. This is the error message:</p>"
         echo 
    "<p><strong>" mysql_error() . "</strong></p>"
         echo 
    "Please Contant Your Systems Administrator with the details"

    return 
    $link




    function 
    html_form() { 

    $conn my_conn(); 
    $sql "SELECT DISTINCT COURSE_NAME FROM COURSES";

    $result mysql_query($sql$conn); 
    if (!
    $result) { 
        echo(
    "<p>Error performing query: " mysql_error() . "</p>"); 
        exit(); 

    ?>

    <p>Please enter the Course Name</p>

    <form name="courses" method="post" action="<? echo $_SERVER['update/PHP_SELF']; ?>"> 
    Name of Course: <select name="COURSE_NAME"> 
    <? 
    while ($row mysql_fetch_array($resultMYSQL_ASSOC)) { 
        echo(
    "<option value=\"" $row["COURSE_NAME"] . "\">" $row["COURSE_NAME"] . "</option>\n"); 

    ?> 

     </select> 
    <input type="submit" name="submit" value="ViewCourses" /> 
    </form> 
    <?


    /* Closes Connection to the MySQL server */ 

    mysql_close ($conn); 



    function 
    select_course() { 
    ?> 
    <h4>COURSES</h4> 

    <? 
    $conn 
    my_conn(); 

    $sql "SELECT * FROM COURSES"
    $sql .= " WHERE (COURSE_NAME = '{$_POST['course']}')"


    /* Passes a Query to the Active Database */ 

    $result mysql_query($sql$conn); 


    /* Starts the table and creates headings */ 
    ?> 
    <table> 
    <tr> 
    <td><strong>COURSE ID</strong></td> 
    <td><strong>COURSE NAME</strong></td> 
    <td><strong>FEES</strong></td> 
    <td><strong>DESCRIPTION</strong></td> 
    <td><strong>NAME OF ORGANISATION </strong></td> 
    </tr> 
    <? 
    /* Retrieves the rows from the query result set 
    and puts them into a HTML table row */ 

    while ($row mysql_fetch_array($resultMYSQL_ASSOC)) { 
        echo(
    "<tr>\n<td>" $row["COURSE_ID"] . "</td>"); 
        echo(
    "<td>" $row["COURSE_NAME"] . "</td>"); 
        echo(
    "<td>" $row["FEES"] . "</td>"); 
        echo(
    "<td>" $row["COURSE_DISCRIPTION"] . "</td>"); 
        echo(
    "<td>" $row["NAME_OF_ORGANISATION"] . "</td>"); 


    /* Closes the table */ 
    ?> 
    </table> 
    <? 

    /* Closes Connection to the MySQL server */ 

    mysql_close ($conn); 


    /* Displays HTML Form */ 
    html_form(); 

    ?> 
    </body>

    </html>

  2. #2
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if (!$_REQUEST['Submit']) { 
    // <snip>
    <input type="submit" name="submit" value="ViewCourses" /> 
    $_REQUEST['Submit'] doesn't exist -- the submit button is named 'submit', and PHP is case-sensitive (not just in variable names).

    Change either to: $_REQUEST['submit'] or name="Submit"
    My name is Steve, and I'm a super-villian.

  3. #3
    SitePoint Zealot Fizlar's Avatar
    Join Date
    Aug 2003
    Location
    Sheffield
    Posts
    179
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yep did that still no change in the result

  4. #4
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Fizlar
    yep did that still no change in the result
    Also, replace:

    PHP Code:
    if (!$_REQUEST['submit']) { ... } 
    with:

    PHP Code:
    if (!isset($_REQUEST['submit'])) { ... } 
    My name is Steve, and I'm a super-villian.

  5. #5
    SitePoint Zealot Fizlar's Avatar
    Join Date
    Aug 2003
    Location
    Sheffield
    Posts
    179
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cheers again.... but still when i click i get no results!

  6. #6
    SitePoint Evangelist Aska's Avatar
    Join Date
    Aug 2003
    Location
    Melbourne, Australia
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Fiz

    This line looks a bit dodgy...
    PHP Code:
    <form name="courses" method="post" action="<? echo $_SERVER['update/PHP_SELF']; ?>">
    Do you mean to do:
    PHP Code:
    <form name="courses" method="post" action="update/<? echo $_SERVER['PHP_SELF']; ?>">

  7. #7
    SitePoint Evangelist Aska's Avatar
    Join Date
    Aug 2003
    Location
    Melbourne, Australia
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also in your select_course() function, you had a $_POST['course']... shouldn't this be $_POST['COURSE_NAME'] instead? Cheers mate.

  8. #8
    SitePoint Zealot Fizlar's Avatar
    Join Date
    Aug 2003
    Location
    Sheffield
    Posts
    179
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    alright mate...

    yeah have changed that still getting no result from it... ie

    (the whole script is a bit poor actually... reading an tutorial on how to update your db online... so trying to do an admin page where users can update and delete data etc) but i have changed what i can ie put improvements where i know i can

    but anyway still no course results are being shown!

  9. #9
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Fizlar
    alright mate...

    yeah have changed that still getting no result from it... ie

    (the whole script is a bit poor actually... reading an tutorial on how to update your db online... so trying to do an admin page where users can update and delete data etc) but i have changed what i can ie put improvements where i know i can

    but anyway still no course results are being shown!
    Hmm, last try before I rewrite the whole script for you

    Shouldn't:
    PHP Code:
    action="<? echo $_SERVER['update/PHP_SELF']; ?>"
    Be:

    PHP Code:
    action="<? echo $_SERVER['PHP_SELF']; ?>"
    Otherwise, you'll be creating a blank action field
    My name is Steve, and I'm a super-villian.

  10. #10
    SitePoint Zealot Fizlar's Avatar
    Join Date
    Aug 2003
    Location
    Sheffield
    Posts
    179
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    whoa its gone crazy now!!

    check it out http://www.burngreave.net/~fizlar/editform.php

    PHP Code:
    <?
    if (!isset($_REQUEST['submit'])) {
           
    html_form(); 
    } else { 
         
    select_course(); 



    function 
    my_conn() { 
    $server "localhost";  
    $username "***";  
    $password "****"

    $link mysql_connect ($server$username$password
    or die (
    "Could not connect"); 

    if (!@
    mysql_select_db("fizlar2"$link)) {    
         echo 
    "<p>There has been an error. This is the error message:</p>"
         echo 
    "<p><strong>" mysql_error() . "</strong></p>"
         echo 
    "Please Contant Your Systems Administrator with the details"

    return 
    $link




    function 
    html_form() { 

    $conn my_conn(); 
    $sql "SELECT DISTINCT COURSE_NAME FROM COURSES";

    $result mysql_query($sql$conn); 
    if (!
    $result) { 
        echo(
    "<p>Error performing query: " mysql_error() . "</p>"); 
        exit(); 

    ?>

    <p>Please enter the Course Name</p>

    <form name="courses" method="post" action="update/<? echo $_SERVER['PHP_SELF']; ?>"> 
     
    <? 
    while ($row mysql_fetch_array($resultMYSQL_ASSOC)) { 
        echo(
    "<option value=\"" $row["COURSE_NAME"] . "\">" $row["COURSE_NAME"] . "</option>\n"); 

    ?> 

     </select> 
    <input type="submit" name="submit" value="ViewCourses" /> 
    </form> 
    <?


    /* Closes Connection to the MySQL server */ 

    mysql_close ($conn); 



    function 
    select_course() { 
    ?> 
    <h4>COURSES</h4> 

    <? 
    $conn 
    my_conn(); 

    $sql "SELECT * FROM COURSES"
    $sql .= " WHERE (COURSE_NAME = '{$_POST['course']}')"


    /* Passes a Query to the Active Database */ 

    $result mysql_query($sql$conn); 


    /* Starts the table and creates headings */ 
    ?> 
    <table> 
    <tr> 
    <td><strong>COURSE ID</strong></td> 
    <td><strong>COURSE NAME</strong></td> 
    <td><strong>FEES</strong></td> 
    <td><strong>DESCRIPTION</strong></td> 
    <td><strong>NAME OF ORGANISATION </strong></td> 
    </tr> 
    <? 
    /* Retrieves the rows from the query result set 
    and puts them into a HTML table row */ 

    while ($row mysql_fetch_array($resultMYSQL_ASSOC)) { 
        echo(
    "<tr>\n<td>" $row["COURSE_ID"] . "</td>"); 
        echo(
    "<td>" $row["COURSE_NAME"] . "</td>"); 
        echo(
    "<td>" $row["FEES"] . "</td>"); 
        echo(
    "<td>" $row["COURSE_DISCRIPTION"] . "</td>"); 
        echo(
    "<td>" $row["NAME_OF_ORGANISATION"] . "</td>"); 


    /* Closes the table */ 
    ?> 
    </table> 
    <? 

    /* Closes Connection to the MySQL server */ 

    mysql_close ($conn); 


    /* Displays HTML Form */ 
    html_form(); 

    ?> 
    </body>

    </html>

  11. #11
    SitePoint Zealot Fizlar's Avatar
    Join Date
    Aug 2003
    Location
    Sheffield
    Posts
    179
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    action="<? echo $_SERVER['update/PHP_SELF']; ?>
    yep did that still same see link!! why has it gone all crazy?

  12. #12
    SitePoint Evangelist Aska's Avatar
    Join Date
    Aug 2003
    Location
    Melbourne, Australia
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Checked your HTML source, you might want to replace the <form> line with:
    PHP Code:
    <form name="courses" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    (exactly as it is) Does it help?
    Also the start tag of <select name="COURSE_NAME"> seems to be missing as well...

  13. #13
    SitePoint Zealot Fizlar's Avatar
    Join Date
    Aug 2003
    Location
    Sheffield
    Posts
    179
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    still no change i am afraid!! what tag am i missing?
    (once again Aska thanx for helping me out)

  14. #14
    SitePoint Evangelist Aska's Avatar
    Join Date
    Aug 2003
    Location
    Melbourne, Australia
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problem. Just below your <form name="courses" method="post" ...> line, put in this:
    HTML Code:
    <select name="COURSE_NAME">
    You probably removed it by accident... it was in your earlier code.

  15. #15
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Edit:

    Aska got it, n'm...
    Mike
    It's not who I am underneath, but what I do that defines me.

  16. #16
    SitePoint Zealot Fizlar's Avatar
    Join Date
    Aug 2003
    Location
    Sheffield
    Posts
    179
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    good spot... fixed the crazyness but still not responding to the drop down menu

    ie still no results

  17. #17
    SitePoint Evangelist Aska's Avatar
    Join Date
    Aug 2003
    Location
    Melbourne, Australia
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm... have you fixed the $sql query in your select_course() function?
    PHP Code:
    $sql "SELECT * FROM COURSES";
    $sql .= " WHERE (COURSE_NAME = '"$_POST['COURSE_NAME']. "')"

  18. #18
    SitePoint Zealot Fizlar's Avatar
    Join Date
    Aug 2003
    Location
    Sheffield
    Posts
    179
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    NO...but have now... very poor mistake by me! cheers Aska. Sure i will be back soon with more probs

    once again cheers

  19. #19
    SitePoint Evangelist Aska's Avatar
    Join Date
    Aug 2003
    Location
    Melbourne, Australia
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Glad to help Cheers~


Bookmarks

Posting Permissions

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