Jump to content


Photo

PHP, MySQL easy quick santax question


  • Please log in to reply
2 replies to this topic

#1 anthonydamasco

anthonydamasco
  • Members
  • PipPipPip
  • Advanced Member
  • 92 posts

Posted 07 September 2006 - 02:36 PM

Really simple

I have 2 columns in a table that I want people to be able to search from

here is my php


$result = mysql_query("SELECT * FROM employees WHERE firstname or lastname LIKE '%$search%'");


i know "or" is wrong, because its only searching the "lastname" column, what is the correct santax?

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 07 September 2006 - 02:37 PM

$result = mysql_query("SELECT * FROM employees WHERE firstname LIKE '%$search%' OR lastname LIKE '%$search%'");

OR is correct.

Info: PHP Manual


#3 anthonydamasco

anthonydamasco
  • Members
  • PipPipPip
  • Advanced Member
  • 92 posts

Posted 07 September 2006 - 02:38 PM

well the way i used it wasnt, lol, thank you




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users