Thundarfoot Posted January 15, 2008 Share Posted January 15, 2008 I am using this query to return all records from a mysql table that contain the value bob in the class column of the db table. I was about to make a bob.php, steve.php, and nancy.php using the same code below except changing the LIKE 'Bob%' to either steve or nancy. then learn to make a form to chose between bob, steve, or nancy.(about 75 diffrent names) However, I am thinking that it should be possible to make the LIKE 'Bob%' a varriable read from a selection box or something, just not sure.. Anyway this is the query, can Bob be replaced with form output or something? Thank you for your time. $query_ClassSelect = "SELECT Name, `Class`, Days, Comments, Pic FROM table WHERE table.`Class` LIKE 'Bob%' ORDER BY Name ASC"; Quote Link to comment Share on other sites More sharing options...
p2grace Posted January 15, 2008 Share Posted January 15, 2008 Sure it can // assuming you've already created the form $name = $_POST['name']; $query_ClassSelect = "SELECT Name, `Class`, Days, Comments, Pic FROM table WHERE table.`Class` LIKE '$name%' ORDER BY Name ASC"; Quote Link to comment Share on other sites More sharing options...
Thundarfoot Posted January 15, 2008 Author Share Posted January 15, 2008 Thank you No I haven't created the form yet, in fact I don't know how to make the form yet, I will have to learn. but did not want to get sidetracked off my project to try to make the form, if It wasent going to work the way I wanted. On a side note I think its neat that I could see the fact I could use a variable there, even not knowing how...to me it means my grasp of the language is improving.. Anyway again thanks for the explanation! Quote Link to comment Share on other sites More sharing options...
p2grace Posted January 15, 2008 Share Posted January 15, 2008 Here's an basic example of the form. Make sure this is below the php code I gave you earlier <form name="form" id="form" action="index.php" method="post" enctype="multipart/form-data"> <select id="name" name="name"><option value="bob">Bob</option><option value="steve">Steve</option></select> <input type="submit" value="Submit" /> </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.