I hate PHP, but I have to do this. I have spent the last 2 days searching for a simple way to write a SQL Select with a LIKE clause where the parameter is passed from the lname
input text on the form. Now, it has to be SQL Server
, NOT MYSQL
So here is what I've done so far.
function getActorDetailsLnameOnly($lname) {
// the SQL query to be executed on the database
$query = "select NameFirst, NameLast, Age, Gender from actor where NameLast like '%$lname%'";
return executeQuery($query);
}
on the index.php, I wrote the following:
if ((!empty($_REQUEST['lname'])) and ( empty($_REQUEST['age']) and ( empty($_REQUEST['gender'])))) {
$lname = (string) $_GET['lname'];
$sql = getActorDetailsLnameOnly($lname);
foreach ($sql as ...) {
extract(...);
...
The code returns a value, but it's nowhere near correct. It's like requesting A in the select statement and it's returning Z. I can't figure it out.