winston1984
IS-IT--Management
I have a piece fo code (below) which lists all the brands from a mySQL database. However, one of the brands has a space it it, it is '4 STAR', it only returns the '4', not the 'STAR', why is this? It is stored as varchar in the database.
<?
if ($currGroup != '') {
$query = "SELECT DISTINCT Products.ProdBrand FROM ProdCat INNER JOIN ProdGroup ON ProdCat.CatCode = ProdGroup.CatCode AND ProdCat.CatCode = ProdGroup.CatCode INNER JOIN Products ON ProdGroup.DeptID = Products.Department WHERE (ProdCat.CatCode = '".$currGroup."' ORDER BY ProdBrand";
} else {
$query = "SELECT DISTINCT(ProdBrand) FROM Products ORDER BY ProdBrand";
};
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
$item = $row['ProdBrand'];
if ($item == $currBrand) {
echo "<option value='".$item."' selected>".$row['ProdBrand']."</option>";
} else {
echo "<option value=".$item.">".$row['ProdBrand']."</option>";
}
}
?>
Help please...
<?
if ($currGroup != '') {
$query = "SELECT DISTINCT Products.ProdBrand FROM ProdCat INNER JOIN ProdGroup ON ProdCat.CatCode = ProdGroup.CatCode AND ProdCat.CatCode = ProdGroup.CatCode INNER JOIN Products ON ProdGroup.DeptID = Products.Department WHERE (ProdCat.CatCode = '".$currGroup."' ORDER BY ProdBrand";
} else {
$query = "SELECT DISTINCT(ProdBrand) FROM Products ORDER BY ProdBrand";
};
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
$item = $row['ProdBrand'];
if ($item == $currBrand) {
echo "<option value='".$item."' selected>".$row['ProdBrand']."</option>";
} else {
echo "<option value=".$item.">".$row['ProdBrand']."</option>";
}
}
?>
Help please...