0
Good
I am with the following problem I am entering multiple data through checkbox that part already working now I wanted to do the validation to mark the box of those that are already inserted in the database but I am not getting are all marked.
Code
<?php
$result_cat=mysql_query("select * from colecoes where activo=1");
while($row_cat=mysql_fetch_object($result_cat)){
?>
<div style="float: left; margin: 5px 5px 5px 0px;"><input type="checkbox" <?php // if($_REQUEST['categoria'] == $row_cat->categoria_slug) echo "checked='checked'"; ?> name="categoria[]" value="<?php echo $row_cat->slug; ?>" /> <?php echo $row_cat->titulo; ?></div>
<?php
}
?>
Table Categories Products
CREATE TABLE IF NOT EXISTS `categorias_estabelecimentos` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`estabelecimento_id` int(11) NOT NULL,
`categoria_slug` varchar(250) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
Appear all selected
– César Sousa
So why this expression -> $_REQUEST['category'] === $row_cat->categoria_slug, is true. What would be the expression or what you would need to compare to to see whether or not the check should be selected?
– Rafael Withoeft
I need it to check in the database for a product which are the categories you have inserted there and present as selected
– César Sousa
Okay and what would be this table and what would be the field?
– Rafael Withoeft
I edited the article and put the table structure
– César Sousa
Dude is a little confused, what would be your table collections up there, what’s your link with categories_establishments? the $_REQUEST['category'], would need to be compared with which table after all to arrive at the 'checked' result you would need? Do you take this establishment out of somewhere? How does your logic work? It’s just a checked for any establishment or it can be multiple?
– Rafael Withoeft
The collection table is where I will find the categories to list them along with the option to select I need to compare in the table categories_establishments the category field
– César Sousa
@Césarsousa Try with the changes I posted now. I could not test, any error warn...
– Rafael Withoeft
It worked right thanks for the help
– César Sousa
@Césarsousa Dispo
– Rafael Withoeft