I have categories in table I want to select data where category is Sales I am using following query
$query = mysql_query("SELECT * FROM catalog_Master where category=@"Sales"");
I have categories in table I want to select data where category is Sales I am using following query
$query = mysql_query("SELECT * FROM catalog_Master where category=@"Sales"");
Wrap it with single quotes because it is a string.
$query = mysql_query("SELECT * FROM catalog_Master where category='Sales'");
based on your comment, if you want the value from a variable,
$category="Sales";
$query = mysql_query("SELECT * FROM catalog_Master where category='$category'");
As a sidenote, the query is vulnerable with SQL Injection
if the value(s) of the variables came from the outside. Please take a look at the article below to learn how to prevent from it. By using PreparedStatements
you can get rid of using single quotes around values.
be careful with the double quotes, also if it's an exact match:
$query = mysql_query("SELECT * FROM catalog_Master where category='Sales'");
This should work
<?PHP
$query = mysql_query("SELECT * FROM catalog_Master WHERE category='Sales'");
?>
**EDIT**
**PHP 5.5 way**
$mysqli = new mysqli("localhost", "db_user", "db_password", "db_name");
$result = $mysqli->query("SELECT * FROM catalog_Master WHERE category='Sales'");