hello,
i would like retrieve value chekbox from DB table join.
for an Update page,
my SELECT table ‘pages’
$q = "SELECT p.user_id,p.status, p.title, p.cat_p_id, GROUP_CONCAT(t.tag) AS tag , p.summary, p.ingredient, p.recipe, p.tips, p.filename
FROM pages AS p
LEFT JOIN pages_tag AS pt USING (page_id)
LEFT JOIN tag AS t USING(tag_id)
WHERE p.page_id=?";
for $tag , the result is for example:
$tag=(végétarien,classique);
I must transform this result as
$tag(végétarien,1);
$tag(classique, 5);
because in my table ‘Tag’ = (tag,tag_id).
“végetarien” => ‘1’ ,“végétalien” => ‘2’, “sans gluten” =>‘3’,“sans lactose”=> ‘4’,“classique” => ‘5’
How can I do to assign property values to the right checkbox ?
Thanks
best regards
the html form for checkbox
<div class="checkbox form-control">
<label for="tag" class="control-label">Tag</label>
<?php
$qt="SELECT tag, tag_id FROM tag ORDER BY tag DESC";
$r=mysqli_query($dbc,$qt);
while ($rowt=mysqli_fetch_array($r, MYSQLI_ASSOC)) { ?>
<div class="checkbox <?php if(array_key_exists('tag', $update_page_errors)) echo ' has-error'; ?>">
<label>
<input type="checkbox" name="tag[]" id="<?php echo $rowt['tag'] ?>" value="<?php echo $rowt['tag_id'] ?>"
<?php if( isset($tag) && ($tag_id == $rowt['tag_id']) ) echo !empty('checked="checked"')?'checked="checked"':'';?>><?php echo $rowt['tag'] ?>
</label>
</div>
<?php if(array_key_exists('tag', $update_page_errors)) echo'<span class="help-bloc">'.$update_page_errors['tag'].'</span>'; ?>
<?php } ?>
</div>