Ugluth Posted October 14, 2008 Share Posted October 14, 2008 Hello, i got a question. First of all i'm using wamp server 2.0 on windows xp sp2 platform and dreamweaver 8.0 edition. I have a database on the wamp server on mysql and i've made a connection through dreamweaver which works fine. Now the thing is i wanna make a display page that has a dropdown list where you can choose a movie category (the database is for a videoclub) and once you choose it from the dropdown list you get the responding table with the movies. My problem is that i don't know how to set the query on the table that will be showing the movies to match the value of the dropdown list. More specifically i need to know what to set on the WHERE. It should look like Movies.category = dropdownlist.value or something similar, but i dont know what exactly and i haven't been able to find anything for it on the internet. Please help if you can and thanks in advance! P.S. Here's the query i'm using if it helps SELECT movies.Movie_Name, movies.Release_Date, movies.Movie_Medium, movies.Rental_Time, categories.Category_Name FROM movies, categories WHERE movies.Movie_Category = '?' the '?' is the thing i'm missing Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 14, 2008 Share Posted October 14, 2008 It would help to post the code you are using. Please use the code tags (# icon in editor). Quote Link to comment Share on other sites More sharing options...
trq Posted October 14, 2008 Share Posted October 14, 2008 Can we see your dropdown? Quote Link to comment Share on other sites More sharing options...
Ugluth Posted October 14, 2008 Author Share Posted October 14, 2008 If i'm not mistaken this is what you asked for <form id="form1" name="form1" method="post" action=""> <label>Categories <select name="CategMen" size="1" id="CategMen"> <option value=""></option><?php do { ?> <option value="<?php echo $row_Categories['Category_ID']?>"><?php echo $row_Categories['Category_Name']?></option> <?php } while ($row_Categories = mysql_fetch_assoc($Categories)); $rows = mysql_num_rows($Categories); if($rows > 0) { mysql_data_seek($Categories, 0); $row_Categories = mysql_fetch_assoc($Categories); } ?> </select> </label> </form> Quote Link to comment Share on other sites More sharing options...
Ugluth Posted October 14, 2008 Author Share Posted October 14, 2008 Would you like the code of the rest of the page as well or some other info about the situation? Quote Link to comment Share on other sites More sharing options...
trq Posted October 14, 2008 Share Posted October 14, 2008 You will find the data your looking for within $_POST['CategMen']. Quote Link to comment Share on other sites More sharing options...
Ugluth Posted October 14, 2008 Author Share Posted October 14, 2008 Hmm i can't use that in the query as it is, i tried putting a variable to the query window, which had as runtime value $_POST['CategMen'] but it still doesn't work as its supposed to, ty for the help though Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 14, 2008 Share Posted October 14, 2008 You should probably post how these 2 db tables are structured: movies, categories Quote Link to comment Share on other sites More sharing options...
Ugluth Posted October 15, 2008 Author Share Posted October 15, 2008 Movies is the main table, which has a movie id as primary key, and also has a category field which contains the category id. The category field is foreign key to the movies table, mapping to a table called categories, which has an id. I hope this made sense. Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 15, 2008 Share Posted October 15, 2008 $movie_cat = isset($_POST['CategMen']) ? $_POST['CategMen'] : ""; SELECT movies.Movie_Name, movies.Release_Date, movies.Movie_Medium, movies.Rental_Time, categories.Category_Name FROM movies, categories WHERE movies.Movie_Category = '$movie_cat' Does this work? And I'm not sure what you mean by "i tried putting a variable to the query window, which had as runtime value $_POST['CategMen'] but it still doesn't work as its supposed to" What query window? Is that a dreamweaver thing? Quote Link to comment Share on other sites More sharing options...
Ugluth Posted October 15, 2008 Author Share Posted October 15, 2008 Yes the variable thingy is a dream weaver feature. I think this should work, or at least it sounds correct to me, but i just realized that my menu doesn't have auto post back enabled. I'm not really sure how that is called, thats how it was called on asp, the option that makes it refresh the page whenever another value was selected. If you can help me with that too i would be grateful! Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 15, 2008 Share Posted October 15, 2008 should be easy... just add a submit button to your form. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.