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>
<form action="validate.php3" method="get">
<p><select name="sel_video" size="6">
<?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!");
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>
<body>
<?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!");
?>
<p>You selected Video : <? echo $sel_video ?></p>
<p>The video ID for this video is : <? echo $sel_vid_id ?></p>
<p>The Publisher for this video is : <? echo $vid_pub ?></p>
</body>
</html>
[/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).]
$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...
Bookmarks