Jump to content

How to select all entires in a column?


gigabyt3r

Recommended Posts

You just wouldn't specify a condition, for example:

 

$sql = "select * from colours";

if (isset($_POST['Colour']))
{
    $colour = mysql_real_escape_string($_POST['Colour']);
    $sql .= " where colour='{$colour}'";
}

// run query

You just wouldn't specify a condition, for example:

 

$sql = "select * from colours";

if (isset($_POST['Colour']))
{
    $colour = mysql_real_escape_string($_POST['Colour']);
    $sql .= " where colour='{$colour}'";
}

// run query

 

Thanks for the reply although im not sure how to implement is :S This is my query so far its quite big

 

$query_rsVehicle = "SELECT ID, `Vehicle Registration`, Make, Model, Color, Transmission, `Fuel Type`, Mileage, `Reg Year`, `Image Prefix`, `Key Point 1`, `Key Point 2`, `Key Point 3`, `Key Point 4` FROM vehicles WHERE Model LIKE \"%$Search%\" AND Wheelbase IN ('$Wheelbase') AND `Roof Height` IN ('$RoofHeight') AND Color LIKE ('$Colour')";   

Try this:

 

$colour_condition = '';
if (isset($_POST['Colour']))
{
    $colour = mysql_real_escape_string($_POST['Colour']);
    $colour_condition = "and Color='$colour'";
}

$query_rsVehicle = "SELECT ID, `Vehicle Registration`, Make, Model, Color, Transmission, `Fuel Type`, Mileage, `Reg Year`, `Image Prefix`, `Key Point 1`, `Key Point 2`, `Key Point 3`, `Key Point 4` FROM vehicles WHERE Model LIKE \"%$Search%\" AND Wheelbase IN ('$Wheelbase') AND `Roof Height` IN ('$RoofHeight') $colour_condition";

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.