How do I get this php statement that gets all the values from database and outputs as checkboxes to

Posted by ggfan on Stack Overflow See other posts from Stack Overflow or by ggfan
Published on 2010-04-12T16:44:45Z Indexed on 2010/04/12 17:12 UTC
Read the original article Hit count: 167

Filed under:

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>";
  }

© Stack Overflow or respective owner

Related posts about php