php & mysql toolbox
CHAPTER 9
Your PHP & MySQL Toolbox The Risky Jobs Search script required quite a few new PHP and MySQL techniques. Let’s recap some of the most important ones.
LIKE
Use LIKE to look for data within explode(), implode() an SQL query without necessarily T he PHP explode() fu requiring an identical match. Put br eaks a string apart nction a % in front of and/or after a array of substrings into an search term to let LIKE know separated by a com that are that the term can have other such as a space or comon delimiter, characters surrounding it. implode() does the mma. builds a single stringopposite - it array of strings, in from an delimiter between thserting a em. str_replace()
switch-case
Call this PHP function to do a find-and-replace on a string of text, replacing one character or sequence of characters with another.
A PHP decision-making const that allows you to execute ruct many groups of code based one of single value. If you find youron a with a bunch of nested if- self statements, you may find thelse you can code it more effic at as a switch statement. iently
560
Chapter 9
LIMIT
substr()
a This PHP function extracts portion of a string based on can arguments you supply it. You , grab the beginning of a stringpiece the end of a string, or some in between.
Custom function
A chunk of PHP code organized into a named, reusable package. The idea is to isolate code that performs a certain task so that it can be reused with minimal effort and code duplication.
The LIMIT clause lets you control exactly how many rows are returned by an SQL query. Not only that, but LIMIT can skip rows in the result set, allowing you to isolate a subset of results.