Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.