Jump to content

Need help with Script? Thank you for your help!


bchandel

Recommended Posts

what will be the correct form of this script to Select * FROM Business WHERE City, or State or Country met criterias entered by visitors as form output. Where do I put necessary " or ' or ; or { etc needed to make it work

 

<?php

$db_connect = mysql_connect("xxx.com", "xxx_user", "password");

mysql_select_db("xxx_database", $db_connect) or die( "Unable to select database");

 

$query = SELECT * FROM Business WHERE 'City' LIKE '%$variable%' or State LIKE '%variable%' or Country Like '%variable';

 

 

$result = mysql_query($query);

$num=mysql_num_rows($result);

?>

Thank you for your help. I made the corrections. However, when I am submitting form even putting any values for City, State, or Country it is displaying all the records in the database. What do I need to do to limit records display unless some one enter some values?

 

One more thing I want to do is to echo $num records found if query meets search criteria or no records found if query does not meet the criteria.

 

Thank 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.