Each item within double quotes is a literal string. The example you inquire about dynamically builds an SQL statement.
For example, if $searchtype is "author_name" and $searchterm is "Rasmus", then you would build a statement like: select * from books where author_name like '%Rasmus%'; The SQL statement should be terminated by a semicolon, I believe, and that appears to be missing from your example. "Beginning of double quote and then beginning single quote beacuse it is the beginning of a string which then ends before the variable $searchterm." This is incorrect. The $searchterm is a part of the string. In the SQL statement above, '%Ramus' is the result of concatenating "'%" with the value of $searchterm with "%'". Basically, you just want to achieve your SQL statement, regardless of the logic you use to do that. An SQL statement is just a string, so there are numerous ways to contruct one. Chris Anthony Ritter wrote: >I want to make sure about the syntax using mysql and PHP. > >Here is the line of code: > >$query="SELECT * FROM books WHERE ". $searchtype. " LIKE '%" .$searchterm. >"%' "; >............................................. > >Am I correct that the reason for the single quote within the expression >above is that: > >"SELECT * FROM books WHERE" // Beginning and end double quotes before the >variable $searchtype > >. // concatation operator > >$searchtype // variable > >. // concatation operator > >"LIKE '%" // Beginning of double quote and then beginning single quote >beacuse it is the beginning of a string which then ends before the variable >$searchterm. > >. // concatation operator > >$searchterm // variable > >. // concatation operator > >"%' "; // beginning of double quote for regex synmbol which then ends the >string and then an end double quote. > >Thank you. >Tony Ritter > > > > > > > > > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php