SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2000
    Location
    Grand Rapids, MI
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Another lengthy message:

    I think I have this setup right, but the outcome isn't right at all. What I'm doing is learning php and mysql, and I setup a couple of pages, index.php3 is my main page, and when you hit 'submit', a variable is passed to validate.php3.

    The code for index.php3 is below: This simply searches MYSQL for all the entries in the vidname column in the video table, then puts those values in a select box.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">code/font><HR><pre>
    &lt;form action="validate.php3" method="get"&gt;
    &lt;p&gt;&lt;select name="sel_video" size="6"&gt;
    &lt;?php
    mysql_connect (localhost, username, password);
    mysql_select_db (gfvideo);
    $query = "SELECT * FROM video ORDER BY vidname";
    $videoinfo = mysql_query($query) or die("Select Failed!");

    while ($videoname = mysql_fetch_array($videoinfo)) {
    echo "&lt;option&gt;";
    echo $videoname['vidname'];
    echo "&lt;/option&gt;";
    } ?&gt;
    &lt;/select&gt;&lt;/p&gt;
    &lt;p&gt;&lt;br&gt;
    &lt;input type="submit" value="Go"&gt; &lt;/p&gt;
    &lt;/form&gt;[/code]

    The index.php3 passes the video name to validate.php3 with no problems (suprisingly).

    In my validate.php3, I just want to show the selection that the user made from index.php3, then re-access the database and get the id number (from field 'id') and the publisher (field 'publisher'). Here is where it doesnt work.

    Code from validate.php3 ----
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">code/font><HR><pre>
    &lt;body&gt;
    &lt;?php
    mysql_connect (localhost, username, password) or die("Unable to Connect to MySQL Server");
    mysql_select_db (gfvideo) or die("Unable to select DB");
    $query = "SELECT id FROM video WHERE vidname='$sel_video'";
    $sel_vid_id = mysql_query($query) or die("Select for ID Failed!");
    $query = "select publisher FROM video WHERE vidname='$sel_video'";
    $vid_pub = mysql_query($query) or die("Publisher Select Failed!");
    ?&gt;


    &lt;p&gt;You selected Video : &lt;? echo $sel_video ?&gt;&lt;/p&gt;
    &lt;p&gt;The video ID for this video is : &lt;? echo $sel_vid_id ?&gt;&lt;/p&gt;
    &lt;p&gt;The Publisher for this video is : &lt;? echo $vid_pub ?&gt;&lt;/p&gt;
    &lt;/body&gt;
    &lt;/html&gt;
    [/code]

    The problem lies when I select the name from index.php3, I go to validate.php3 and it DOES show the selection for $sel_video, however the new queries, $sel_video_id, and $vid_pub, show up as '2' and '3', respectively, no matter what video I pick from index.php3.

    Any ideas?

    Mike

    ------------------
    My new position : Target for Middle Management Hostility.



    [This message has been edited by mmccue (edited February 26, 2000).]

  2. #2
    RAGE
    SitePoint Community Guest
    $sel_vid_id and $vid_pub are results from the mysql queries.. they are arrays in other words.. u have to use mysql_fetch_array() and parse that data for the row you want .... with the data you want...

    ------------------
    http://www.realmz.net
    Your #1 source of Webmaster Resources

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2000
    Location
    Grand Rapids, MI
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can I get a code example?

    Mike


    ------------------
    My new position : Target for Middle Management Hostility.

  4. #4
    SitePoint Enthusiast
    Join Date
    Feb 2000
    Location
    Grand Rapids, MI
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nevermind, I figured it out. Thanks for your help.

    Mike


    ------------------
    My new position : Target for Middle Management Hostility.


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
  •