i am trying to find the best way possible to somewhat search, a database table for certain information. when the user first goes to a page, he there is two input fields. one is for an ad name and the second is for ad owner.
now, this is what i have for my php code:
- Code: Select all
if( $ad_name )
$sql_where .= "WHERE ad_name LIKE '%$ad_name%'";
else if( $ad_owner )
$ad_owner_convert = get_userdata($ad_owner_convert);
$ad_owner_userid = $ad_owner_convert['ad_owner_userid'];
$sql_where .= "WHERE ad_owner LIKE '%$ad_owner_userid%'";
$sql = "SELECT *
FROM " . ADS_TABLE . "
if( !($result = $db->sql_query($sql)) )
message_die(GENERAL_ERROR, 'Could not perform search correctly', '', __LINE__, __FILE__, $sql);
while( $row = $db->sql_fetchrow($result) )
echo $row['ad_id'] . ' ' . $row['ad_name'] . '<br />';
But i would like to use the best way possible to do this. Could someone help me and also perhaps show me the way to do it using a switch case statements. Thank you in advance! It is most appreciated.