Working on something and having problems with some code. The scenario is that an item should have multiple categories. my solution is to loop create checkboxes so that the user may simply click on the categories the item should have this is the code i have.
<?php
$result = mysql_query("SELECT * FROM tbl_category order by name ");
while($row = mysql_fetch_array($result))
echo '<label>'.$row['name']. '</labe>'
'<input type="checkbox" name="categories" value='.$row['category_id'].' >';
?>
Somehow it’s not working would appreciate any help on this.
Also if someone could give me idea on how to store the values like ITEM APPLE has values of A,G,Y how would i store it in the database and how should show it. because i will be using SELECT ELEMENT filters to search them.
EDIT: error prompt
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ‘,’ or ‘;’ in C:\xampp\htdocs\nota\add2.php on line 25
you are missing an string concatenation operator
.in echo statement .i suppose that your query is correct and there is some data in your database.And about storing
ITEM APPLE has values of A,G,Yyou can use a look up table which has the
idofITEM APPLEand values as A then same id but value as G and then y..etc athis schema is best suited if an item can have multiple value .
link to database schema