Re: Query's

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



HTML File::::

<html>
<body>
<form action="/some/path/script.php3">
Select genre: <select name=genre>
<option value=genre1>Genre 1</option>
-----------
---------
----------
</select>
<select name=style>
<option value=like>Like</option>
<option value=Equal>Exact</option>
</select>
</form>
</body></html>


PHP Script:::::
<?php
if($style='Equal')
 $op='=';
else
 {
 $op='like';
 $genre = '%'.$genre.'%';
 }

mysql_connect("localhost","name","password");
mysql_select_db("oldmovies");
$result = mysql_query ("SELECT * FROM movies where genre $op '$genre'");

 while($r=mysql_fetch_array($result))
   {
     $movie_number=$r["movie_number"];
     $movie_name=$r["movie_name"];
     $genre=$r["genre"];
     $star1=$r["star1"];
     $star2=$r["star2"];
     $star3=$r["star3"];
     $director=$r["director"];
     $brief_synopsis=$r["brief_synopsis"];
     $imdb_link=$r["imdb_link"];
   }
?>



----- Original Message ----- 
From: "Nitin" <nitinmehta@kappa.net.in>
To: "Andrew R" <andrew@htop.org>; <php-db@lists.php.net>
Sent: Tuesday, September 30, 2003 12:21 PM
Subject: Re:  Query's


> What you'll have to do is, first show those drop down menus and then call
> your php script, c the attachment for exact help.
>
> Enjoy
> Nitin
>
> ----- Original Message ----- 
> From: "Andrew R" <andrew@htop.org>
> To: <php-db@lists.php.net>
> Sent: Tuesday, September 30, 2003 3:31 AM
> Subject:  Query's
>
>
> > Howdy List,
> >
> > I am a little confused in incorporating a drop down menu into my select
> > statement.
> > I have a very simple 1 table database that contains my DVD collection.
> >
> > Right now - very simply it connects to the database, and then produces
> > the results of the search based on a
> >
> > <?
> >   mysql_connect("localhost","name","password");
> >   mysql_select_db("oldmovies");
> > $result = mysql_query ("SELECT * FROM movies");
> >
> > while($r=mysql_fetch_array($result))
> >   {
> >     $movie_number=$r["movie_number"];
> >     $movie_name=$r["movie_name"];
> >     $genre=$r["genre"];
> >     $star1=$r["star1"];
> >     $star2=$r["star2"];
> >     $star3=$r["star3"];
> >     $director=$r["director"];
> >     $brief_synopsis=$r["brief_synopsis"];
> >     $imdb_link=$r["imdb_link"];
> >
> >
> > ?>
> > This then produces the results onto the page in the tables that I have
> > formatted.
> >
> >
> > This was fine when I only had 50 or so dvd's - I am nearing the 500
> > mark, and it is WAY past time to add a search
> >
> > This is where I get lost.
> >
> > I can get into mysql monitor, and I can pull out using SELECT * FROM
> > movies WHERE genre LIKE *******
> > And then I have a selection of Genre's that I can enter to generate the
> > results.
> >
> > What I am trying to do is incorporate some selection drop down menus
> > that would make the search process easier.
> >
> > Example: search for movies where {dropdown1} is {equal or like}
> > Dropdown 1 would be my first criteria: movie name, director, lead actor,
> > genre.
> > The equal or like would be a standard textfield to be filled in.
> >
> > I hope that I am making sense here.
> >
> > If anybody can shed some light onto a confused newbie (the php script
> > above was written at my old place of employment for me - otherwise I
> > could ask them) it would be greatly appreciated.
> >
> > Thank you
> > Andrew
> >
> > ------------------------------------------------------
> >
> > "Come to the edge, Life said.
> > They said: We are afraid.
> > Come to the edge, Life said.
> > They came.
> > It pushed them...and they FLEW."
> > -Guillaume Apollinaire 1870-1918
> > -------------------------------------------------------
> > "Once you have tasted flight,
> > you will walk the earth with your eyes turned skyward,
> > for there you have been and there you long to return."
> >
> > -- 
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>


----------------------------------------------------------------------------
----


> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux