Jump to content

WHERE clause in query not working


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
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.