I have a dropdown select form which is based on a "brand" table that has more than 150 brand_name(s) with corresponding brandid(s).
As you can see in the code below, I all the brands/rows will appear in the dropdown form. I'd like to know if there is a way to exclude certain brands (without deleting them from the table; for example: they are temporarily out of stock). And not just LIMIT 1 to 7.
If for example, I want brand_names with brandids 9, 27, 50 etc. not to appear in the select option, how can it be done? Is there an EXCEPT() function of some sort?
<?php
echo "<form action=\"chosen_brand.php\" method=\"get\">\n";
echo "<select name=\"brand_name\">\n";
$stmt = mysqli_stmt_init($link);
if($stmt=mysqli_prepare($link,"SELECT `brandid`,`brand ` FROM `brand ` WHERE `brandid`"))
{
mysqli_stmt_bind_param($stmt,"i", $brandid);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt,$brandid, $brand_name);
while(mysqli_stmt_fetch($stmt))
{
echo "<option value=\"$brandid\"> $brand_name </option>";
}
echo "</select>\n";
echo "<input name=\"submit\" type=\"submit\" id=\"brandid\" value=\"submit\" />\n";
echo "</form> \n";
mysqli_stmt_close($stmt);
mysqli_free_result($result);
}
?>
Thanks, Jen
WHERE brandid NOT IN (9,25,50,etc)
if you aren't actually storing the stock level but have a list of out of stock brands
or perhaps
WHERE stock_level > 0
if you have the individual stock levels per brandid
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.