Run a SQL query based on HTML drop down selection?
- From: Joe <sutcliffe1@xxxxxxxxx>
- Date: Wed, 29 Oct 2008 18:55:11 -0700 (PDT)
This is my HTML form:
<form method=get action="home.php">
<INPUT TYPE = "Text" VALUE = "" NAME = "title"><br>
<select name="searchby">
<option value="Title">Title</option>
<option value="Year">Year</option>
<option value="Genre">Genre</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?
.
- Follow-Ups:
- Re: Run a SQL query based on HTML drop down selection?
- From: Charles Calvert
- Re: Run a SQL query based on HTML drop down selection?
- From: Jerry Stuckle
- Re: Run a SQL query based on HTML drop down selection?
- Prev by Date: Re: Best development platform? Mac, Windows or Linux?
- Next by Date: Re: bollhy"system" function output displays twice last line
- Previous by thread: bollhy"system" function output displays twice last line
- Next by thread: Re: Run a SQL query based on HTML drop down selection?
- Index(es):
Relevant Pages
|