I am a bit lost in all these “” and ” and . in this statement.
Basically this query is to get all the tagname from table “tag” and display them for the users as checkboxes. If they have clicked ‘submit’ and they missed another field(say the title of a post), it would still have the tag they chose displayed. The part I need help with is the echoing part. It doesn’t seem to remember the tag when they click submit.
$query4 = "SELECT * FROM tags ORDER BY tagname";
$data4 = mysqli_query($dbc, $query4);
while ($row4 = mysqli_fetch_array($data4))
{
echo "<li><input type='checkbox' name='postingtag[]'";
if (!empty($postingtag)){
echo "value='$postingtag'";
}
else{
echo "value='{$row4['tagID']}'";
}
echo ">{$row4['tagname']}</li>";
}
Try this:
$postingtagwill be an array that will be populated with tags that have been checked. By adding a discernible index to the$postingtagarray you’ll be able to check to see if its be populated and can then set the checked attribute accordingly.