advice on creating a get variable from from drop down list
Results 1 to 2 of 2

Thread: advice on creating a get variable from from drop down list

  1. #1
    Member
    Join Date
    Feb 2012
    Posts
    33

    advice on creating a get variable from from drop down list

    Hi all,

    I have a drop down list, which pulls data from a MySQL table. This table currently has only two rows, but could certainly have more with eventual data entry.

    The purpose of the drop down is the specify a variable that will then be used on the next page to retrieve only certainly rows from a different table.

    Here's the drop down code I plucked from the Internet (all comments are from the original sample script):

    PHP Code:
    <?php

    // modified from sample script at http://www.plus2net.com/php_tutorial/list-table.php - 03/26/12 rjm

    if(!isset($_SESSION)) 

    session_start(); 

    include(
    'connection.php');

    $query="SELECT feed_title,feed_id FROM feeds";

    /* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */

    $result mysql_query ($query);
    echo 
    "<select name=feed_title value=''>Feed Name</option>";
    // printing the list box select command

    while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
    echo "<option value=$nt[feed_id]>$nt[feed_title]</option>";
    /* Option values are added by looping through the array */
    }
    echo 
    "</select>";// Closing of list box 


    echo " <a href=\"index.php?action=additem\">Feed</a><br>";
    echo 
    "</h2>";

    echo 
    "test";
    echo 
    $nt[feed_id];
    ?>
    What my intention would be is to pass the variable for the selected feed title on when I click the Feed hypertext link. I'm not necessarily married to this we of doing it if there's a more efficient way of doing it.

    Thanks for looking,

    Robert

  2. #2
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,349
    Why not put the <select> entity into a <form> and make the 'Feed' link into a submit button?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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