This is a discussion on Simple Search facility within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi there, I am trying to implement a simple search facility on my DVD shop website. I want to allow ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi there,
I am trying to implement a simple search facility on my DVD shop website. I want to allow the user the ability to search the DVDs by genre. I have the following SQL code to use: select * from DVD where genre LIKE '%Drama%' I am using the LIKE statement as the genre of a film may be Action/Drama for example. I am not sure how to implement this, I want to have links that display the name of each genre and then the page displays the DVDs in that genre. I am not sure what to include in the anchor tag. Any help on this would be great. |
|
|||
|
Sample link on genre page:
<a href="dvd.php?genre=action">Action</a><br/> <a href="dvd.php?genre=drama">Drama</a> DVD Table contains: ID | Genre --------------- 1 | Action 2 | Drama 3 | Action/Drama 4 | Action/Comedy SQL in dvd.php: $rResult = mysql_query("select * from DVD where genre like '%" . $_GET["genre"] . "%'"); When genre = Action, select would return record ID 1, 3 and 4 When genre = Drama, returns record ID 2 and 3 Bryan "James" <nospamheredude@yahoo.com> wrote in message news:buk4hb$sg8$1@hercules.btinternet.com... > Hi there, > I am trying to implement a simple search facility on my DVD shop website. I > want to allow the user the ability to search the DVDs by genre. I have the > following SQL code to use: > > select * from DVD where genre LIKE '%Drama%' > > I am using the LIKE statement as the genre of a film may be Action/Drama for > example. > > I am not sure how to implement this, I want to have links that display the > name of each genre and then the page displays the DVDs in that genre. I am > not sure what to include in the anchor tag. > > Any help on this would be great. > > |