Skip to content Skip to sidebar Skip to footer

How Can I Put Two Search Results Statement As One Using A Conditional Statement?

I need these two separate statements to be one statement using a conditional either if or elseif or even any other conditional statement which will execute any of the two queries a

Solution 1:

the difference is

$doctor = $_GET["txt_doctor"];

you can firstly check $_GET["txt_doctor"]; and then with the code below

if(isset( $_GET["txt_doctor"]))
{
  // second statement
}else
{
// first statement

}

Solution 2:

Your question is very hard to understand. Formatting your code helped me understand your question a little bit more, though...

first query

    SELECT `autoID`, `Name of Doctor`, `Email`, `Hospital of Practise`, `State`, 
           `Specialization`, `Professional Organization`, `webpage` 
    FROM   `doctor_locator`
    WHERE   state = '$states' AND 
            specialization = '$specialize'

second query

       SELECT `autoID`, `Name of Doctor`, `Email`, `Hospital of Practise`, `State`,
              `Specialization`, `Professional Organization`, `webpage` 
        FROM  `doctor_locator`
        WHERE `name of doctor` LIKE 'Dr%' AND state = '$states'

this query only filters for two things. Where the name of the doctor starts with Dr and for the $states. This seems wrong to me... but it is the code that you provided. It seems like there should be a name you're filtering by.

combined

$sql = "SELECT `autoID`, `Name of Doctor`, `Email`,
               `Hospital of Practise`, `State`, 
               `Specialization`, `Professional Organization`, `webpage` 
        FROM   `doctor_locator`
        WHERE   state = '$states' AND 
                specialization = '$specialize' AND
               `name of doctor` LIKE 'Dr%' 

The $states filter was in there twice.

question - it seems like you don't really want the two queries joined, you want them executed separately depending on something. I need to know what determines which query is ran.

  If ($query = "run query 1")  { // run query 1... } 
                          else { // run query 2... }

you didn't provide enough information in your initial post for me to write that logic.

Post a Comment for "How Can I Put Two Search Results Statement As One Using A Conditional Statement?"