Jump to content

Dynamically Generated MySQL Query Based on Form Input.


sfludd83

Recommended Posts

Howdy everyone.

I'm going to start by saying that I'm brand new to PHP/MySQL as far as programming is concerned, so thank you in advance for your responses. -Literally started programming with this about 2-3 weeks ago-

 

I have an HTML form, using the POST method, linked to an external PHP file for processing. The form has only 4 inputs, all of which are dropdown select boxes. The purpose of this form is to complete a search based on the criteria within the four inputs via a MySQL query. My goal is to make it so that the search can be done using any combination of these inputs and any number of them except zero. At least 1 box will always need to be used.

 

I have made attempts at this already. Creating variables and control structures are not a problem for me, though I am still getting a grip on some of the complexities they can entail. I could make separate queries for each and every situation in the form, but that would seem less efficient. Also I'd like to eventually use PHP/MySQL professionally so tackling things like this will come in handy.

 

I have a general idea on how to do this, and I've already made parts of the query dynamically, but when you start doing JOINS it gets super complicated. That's what I will need help with. Also, there are about 3 or 4 separate tables involved in the JOIN query.

 

Thanks again!  8)

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.