Jump to content

PLease Help with my error


Sarajs

Recommended Posts

If this is a paid job i would charge extra time/money for a search engine simply because a search engine can be a VERY complicated feature, especially if you've never done it before.

---

 

FYI it should not matter with "multiple" search fields, something like:

 

<?php


// Build the query
$query = array();

// If artist was needed, add it to the array
if($cd_artist != ""){
   $query[] = "`artist` LIKE '%".$cd_artist."%'"; 
}

// blah blah for all other fields
if($cd_title != ""){
   $query[] = " `title` LIKE '%".$cd_title."%'"; 
}
if($cd_genre != ""){
   $query[] = " `genre` LIKE '%".$cd_genre."%'"; 
}
if($cd_year != ""){
   $query[] = "`year` LIKE '%".$cd_year."%'"; 
}
if($cd_type != ""){
   $query[] = "`type` LIKE '%".$cd_type."%'"; 
}

// now you have an array with only the searches u need. Implode them into a single string with OR between each item;
$query = "SELECT *  FROM tProducts WHERE ".implode(" OR ",$query)." ORDER BY `artist`"; // put OR between each search.

$result = mysql_query($query);

// This loop ust displays each result
while($row=mysql_fetch_array($result)){
   print_r($row); echo("<br />");
}

?>

 

Hope this clears things up for you.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.