This is my HTML form:
<form method=get action="home.ph p">
<INPUT TYPE = "Text" VALUE = "" NAME = "title"><br >
<select name="searchby" >
<option value="Title">T itle</option>
<option value="Year">Ye ar</option>
<option value="Genre">G enre</option>
<option value="Director ">Director</option>
</select>
And here is the relevant PHP query:
$query = "SELECT Title, ReleaseYear, Rating, Director, RunningTime,
Genre
FROM movie
WHERE $searchby LIKE '%$title%'
GROUP BY $searchby";
Assume that "$title" is a string of text (not necessarily a movie
title). My problem seems to be that I cant use the variable $searchby
within a SQL query. Is there a workaround for this?
<form method=get action="home.ph p">
<INPUT TYPE = "Text" VALUE = "" NAME = "title"><br >
<select name="searchby" >
<option value="Title">T itle</option>
<option value="Year">Ye ar</option>
<option value="Genre">G enre</option>
<option value="Director ">Director</option>
</select>
And here is the relevant PHP query:
$query = "SELECT Title, ReleaseYear, Rating, Director, RunningTime,
Genre
FROM movie
WHERE $searchby LIKE '%$title%'
GROUP BY $searchby";
Assume that "$title" is a string of text (not necessarily a movie
title). My problem seems to be that I cant use the variable $searchby
within a SQL query. Is there a workaround for this?
Comment