Когда пользователь редактирует данные в форме, заполненной из базы данных, я пытаюсь предварительно установить флажки, я работаю с 2 массивами, во-первых, это доступные темы,
Array ( [0] => Array (
[topic_id] => 402
[topic_title] => Website Development
[topic_slug] => website-development
[topic_description] => This topic will cover everything form the most CSS to the most advanced PHP. You will learn not only how to code but create maintable code bases that can be authored by various authors with no previous knowledge of the project.
[date_created] => 2011-10-03 17:27:41
)
[1] => Array (
[topic_id] => 404
[topic_title] => j41-ramp-handling
[topic_slug] => j41-ramp-handling
[topic_description] => Ramp handling course for J41
[date_created] => 2011-11-02 23:14:00
)
[2] => Array (
[topic_id] => 405
[topic_title] => aviation-regulations
[topic_slug] =>
[topic_description] => Changes to aviation regulations.
[date_created] => 2011-10-17 10:19:40 ) )
и у меня также есть массив, показывающий, на какие темы подписан пользователь,
Array ( [0] => Array (
[topic_title] => Website Development
[topic_id] => 402
[topic_slug] => website-development
[topic_description] => This topic will cover everything form the most CSS to the most advanced PHP. You will learn not only how to code but create maintable code bases that can be authored by various authors with no previous knowledge of the project.
)
[1] => Array (
[topic_title] => aviation-regulations
[topic_id] => 405
[topic_slug] =>
[topic_description] => Changes to aviation regulations.
))
Первый массив называется $topics
, второй называется $signedup
Я пытаюсь установить флажок по умолчанию, если ttopic id совпадает в обоих массивах, однако, что бы я ни пытался получить, я не ставлю галочку, ниже мой HTML / Код PHP,
<fieldset>
<legend>Topics Sign Up</legend>
<?php $i = 0; ?>
<?php foreach ($topics as $k => $v) : ?>
<?php //var_dump($signedup[$i]['topics_topic_id']); ?>
<label for="topics_topic_id[]" class="checkbox"><?php echo $v['topic_title'];?></label>
<input type="checkbox" name="topics_topic_id[]" value="<?php echo $v['topic_id']; ?>"/>
<?php $i++; ?>
<?php endforeach; ?>
</fieldset>
Как установить флажок по умолчанию, если в подписанном массиве есть идентификатор темы, совпадающий с идентификатором темы?