Jump to content

WHERE clause in query not working


Go to solution Solved by ryntak4536,

Recommended Posts

Hello all,

 

Newbie here...

This WHERE clause in the query of this function is not working, but I cannot figure out why:

    function find_author_list($author_intial){
        global $connection;
        //Perform author query
        $query =     "SELECT * ";
        $query .=     "FROM authors ";
        $query .=    "WHERE Last_Name LIKE \"{$author_initial}%\" ";
        $query .=    "ORDER BY Last_Name ASC";
        $author_set = mysqli_query($connection, $query);
        //test if there was a query error
        confirm_query($author_set);
        return $author_set;
    }

I'm calling it with

$author_set = find_author_list($current_initial);

And instead of limiting it to the initial passed to it, it's returning ALL of the authors in my database.

I've included an echo at the top of my page to show me what $current_initial is, and it's clearly a single letter.

 

Any help is appreciated!

Link to comment
https://forums.phpfreaks.com/topic/295177-where-clause-in-query-not-working/
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.