Not able to do searching

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Alicia
New php-forum User
New php-forum User
Posts: 94
Joined: Sun Sep 21, 2003 5:30 pm

Not able to do searching

Postby Alicia » Sun Sep 21, 2003 8:25 pm

Can somebody help to check my code... i insert a value for c_category and it works fine. But once i inserted a value for c_desc (or with others variable). It does not work anymore. It just shows no results found and display nothing. Did i miss something in my code ?

For your information, i am trying to do a simple search engine where value for c_category is required and the others all optional.

Please advise.


$sql = 'select * from `biz_info` ';
$joiner = 'where ';
if (!empty($c_category))
{
$sql .= "{$joiner}`c_category` LIKE '{$c_category}'";
$joiner = 'and ';
}

if (!empty($c_desc))
{
$sql .= "{$joiner}`c_desc` LIKE '$c_desc'";
$joiner = 'and ';
}

if (!empty($c_name))
{
$sql .= "{$joiner}`c_name` LIKE '$c_name'";
$joiner = 'and ';
}

if (!empty($c_state))
{
$sql .= "{$joiner}`c_country` LIKE '$c_state'";
$joiner = 'and ';
}
//continue for the rest of the variables

$result = mysql_query ($sql) or die ("Query unsucessful, Please try again later.");
include 'include/row.php';
?>

sigix
php-forum Active User
php-forum Active User
Posts: 364
Joined: Mon Jul 14, 2003 9:39 pm
Location: /Earth/Xion

Postby sigix » Tue Sep 23, 2003 5:10 am

seems to be every thing right try this
mysql_query(..)or die(mysql_error())
and see what error it gives


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 0 guests