DS928
asked on
Adding A Field To A List
I have a PHP statement that loads a list box. I have to add the field tblLocDet.DetailID as id, which I did. Now I need to add it to the listbox itself as the first row so that I can call it to filter some records. How do I place it in the while statement? I do not want to see it,.
$sql = "SELECT tblDetails.DetailType AS type, tblLocDet.DetailID AS id,
GROUP_CONCAT(DISTINCT DetailName ORDER BY DetailName ASC SEPARATOR '|') AS DetailName
FROM tblLocations INNER JOIN (tblLocDet INNER JOIN tblDetails
ON tblLocDet.DetailID = tblDetails.DetailID) ON tblLocations.LocationID = tblLocDet.LocationID
GROUP BY tblDetails.DetailType,tblLocations.CityID,tblLocations.AreaID,tblLocations.CuisineID
HAVING (((tblLocations.CityID)='16')
AND ((tblLocations.AreaID)='131')
AND ((tblLocations.CuisineID)='3'))";
$result = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
echo "<optgroup label='{$row['type']}'>";
$DetailNames = explode('|', $row['DetailName']);
foreach($DetailNames as $DetailName) {
echo "<option value='".$DetailName."'>".$DetailName."</option>";
}
echo "</optgroup>";
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thank you.
ASKER
Open in new window