mysql_fetch_assoc
Posted: Wed Jan 28, 2009 11:42 am
I messed something up here though I am not entirely sure what. Here is the code in question:
When I do print_r($customer) nothing shows up. What did I do incorrectly to cause this to happen?
Code: Select all
<?php
include 'common.php';
dbConnect();
$query = "SELECT * FROM customers WHERE 1=1 ";
if ($_POST['Customer_id'] != "")
{
$query .= " AND customer_id = '%" . mysql_real_escape_string($_POST['Customer_id']) . "%' ";
}
if ($_POST['FirstName'] != "")
{
$query .= " AND first_name LIKE '%" . mysql_real_escape_string($_POST['FirstName']) . "%' ";
}
if ($_POST['LastName'] != "")
{
$query .= " AND last_name LIKE '%" . mysql_real_escape_string($_POST['LastName']) . "%' ";
}
if($_POST['State'] != "")
{
$query .= " AND states = '" . mysql_real_escape_string($_POST['State']) . "' ";
}
if ($_POST['City'] != "")
{
$query .= " AND city LIKE '%" . mysql_real_escape_string($_POST['City']) . "%' ";
}
$customer = mysql_fetch_assoc($result[$query]);