getadj()
executes
the
following
MySQL
query:
select adjacent from areacode where code = 21`
It then formats the results, returning a string which looks like:
((areacode = 21`) or (areacode = 22`) or (areacode =
23`) or (areacode = 24`) or (areacode = 25`) or
(areacode = 26`) or (areacode = 27`) or (areacode =
28`)).
This string is inserted as a substring into the main SQL query to be, which will
ultimately
look
like
this:
select * from clients, category where category.cid =
clients.category and ((areacode = 21`) or (areacode =
22`) or (areacode = 23`) or (areacode = 24`) or
(areacode = 25`) or (areacode = 26`) or (areacode =
27`) or (areacode = 28`)) and ((bizname like
%plumber% ) or (pictext like %plumber% )).
Just after the appropriate one of the four SQL query generating functions is called, a
string variable called $foundstring is put together. This is the line that later appears as the
caption of the results table saying, for example, Searched for computer in the Malahide
area, sorted by shop or Searched for plumber in the 021 area and surrounding areas,
sorted by default .
The next major step is to run the query and return the results in a table. If you, the reader
are in a position to execute the source code on an appropriate webserver, it might be
worthwhile to uncomment the line echo $gp; this prints out the exact SQL query above
the results table and was used during development for debugging purposes.
33