SunQuest
 
           General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old April 23rd, 2003, 06:53 PM
stfu stfu is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 19 stfu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Search

hi guys i have this code:

Code:
<tr>
<td align="right">
<p class="searchlabel">
Search:&nbsp;&nbsp;
</p>
</td>
<td>
<form action="search2.php" method="get">
<input type="text" name="se" size="30" maxlength="30" value="">
<select name="second">
<option value="se" selected>Movies</option>
<option value="ac" selected>Actors</option>
</select>
<input class="searchbutton" type="submit" value="Go!">
</form>
</td>
</tr>


i want when i select Actors from Select menu and type some Actor like Nicolas Cage then i press Go! button to show me all movies with this actor
or when i select movies from menu and type some movie like Ronin then i press Go! button to show me this movie i setup this search only for movies but for multiplay searches i don't know how, when search only for movies i use that:

Code:
if ($_GET['se']) {
$se = $_GET['se'];
$result = mysql_query("SELECT movie_id, movie_title FROM movies WHERE movie_title LIKE '%$se%'") or die ("Search query failed!");


any idea how i can do that ?
thanks in advanced

Reply With Quote
  #2  
Old April 23rd, 2003, 10:27 PM
avit avit is offline
Not Yet Perfect
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: Squamish, BC
Posts: 111 avit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to avit
Those are two different queries, so you need to have an if statement based on the value of your "second" form item.

PHP Code:
if ($_GET['second'] == 'se') {
  
// formulate your movies query
} elseif ($_GET['second'] == 'ac') {
  
// formulate your actors query



Is that what you need to know?

Reply With Quote
  #3  
Old April 24th, 2003, 11:43 AM
stfu stfu is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 19 stfu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i think yes but i'm not really sure i wrote this:
PHP Code:
<?php
$second 
$_GET['second'];
if (
$second == "se") {
$results "SELECT movie_id, movie_title FROM movies WHERE movie_title LIKE '%$se%'";
$type "for $se";
$arrWords explode(" "$se);
} elseif (
$second == "ac") {
$results "SELECT movie_id, movie_title FROM movies WHERE starring_actors LIKE '%$ac%'";
$type "for $ac";
$arrWords explode(" "$ac);
};

that is from search when i select for actors
http://80.8.144.38/search3.php?se=nicolas&second=ac
or for movies will be:
http://80.8.144.38/search3.php?se=ronin&second=se

but don't work any idea where i'm wrong ?

Reply With Quote
  #4  
Old April 24th, 2003, 01:36 PM
jpenn jpenn is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Washington, DC
Posts: 317 jpenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 3 sec
Reputation Power: 6
Check those $_GET['vars'] before using them in your queries. Also, no need to use a comparison on the get's - comparisons are slow - use a switch instead ->

PHP Code:
/********************************************
Bind search type and search scalar
********************************************/
$search_type /* Clean your GET['second'] string with some functions */;
$search /* Clean your GET['se'] string with some functions */;
/********************************************
Switch on search type scalar
********************************************/
switch( $search_type )
{
    case 
'se':
    
$query "SELECT movie_id, movie_title FROM movies WHERE movie_title LIKE '%$search%'";
    break;

    case 
'ac':
    
$query "SELECT movie_id, movie_title FROM movies WHERE starring_actors LIKE '%$search%'";
    break;

    default:
    
$query = ( bool )false;
    break;
}
/********************************************
Now check query string, search if not false
********************************************/
if( $query )
{
    
/********************************************
    Hit It
    ********************************************/
    
$result mysql_query$query ) or exit( 'SQL Query Failed:' mysql_error() );
    
/********************************************
    Fetch Results
    ********************************************/
    
while( $res mysql_fetch_object$result ) )
    {
        
/* Format the output here */
    
}
}
else
{
    echo( 
'No search type specified - Please go back!' );


Default in the switch would be if nothing was chosen on the form for the narrowed results...
__________________
~ Joe Penn

We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set?

Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you.




Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Search


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway