[PHP] Basic SQL syntax

2001-01-15 Thread James, Yz

OK, I got a simple search page working (thanks to all of you who helped me).

Another simple question for you.  If I had a search  and the data to be
searched needs to be determined by check boxes, How would I write the sql?
Like this?

$sql = "SELECT * FROM table
  WHERE town LIKE '%$search_data%' OR street LIKE '%$search_data%' ";

Is "OR" even the correct syntax?  Here's how I tried it, which didn't give
any results.

(Where reference is the id number (or map reference) and search_data is the
text field for users to tpye the query.

if ($reference != "")
$search_reference = "OR id LIKE '%$reference%'";
}

$sql = "SELECT * FROM table
  WHERE town LIKE '%$search_data%' $search_reference";

$result = @mysql_query($sql,$connection)
 or die (mysql_error());

$num = mysql_num_rows($result);


TIA,
James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Basic SQL syntax

2001-01-15 Thread James, Yz


""Johannes Janson"" [EMAIL PROTECTED] wrote in message
93vs9u$osj$[EMAIL PROTECTED]">news:93vs9u$osj$[EMAIL PROTECTED]...
 try this:
 $sql = "SELECT * FROM table
   WHERE town LIKE '%$search_data%' ";

 if ($reference != "")
   $sql .= "OR whatever";


Ah, so you can constantiate (right word?) the query?

Cool, Thanks ;)

James.




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Basic SQL syntax

2001-01-15 Thread James, Yz

  Ah, so you can constantiate (right word?) the query?

 I don't know what you mean by 'constantiate', but glad to hear it worked

It did, thank you ;)

Someone pointed out where I'd gone wrong with the word privately:

 Ah, so you can constantiate (right word?) the query?

 concatenate :)




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]