How can I put two search results statement as one using a conditional statement?

前端 未结 2 2048

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 exe

相关标签:
2条回答
  • 2021-01-26 13:54

    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
    
    }
    
    0 讨论(0)
  • 2021-01-26 13:57

    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.

    0 讨论(0)
提交回复
热议问题