Jump to content

[SOLVED] can a query be used with a form?


Thundarfoot

Recommended Posts

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";

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.