Bu kod ile bir MySQL veritabanı onay kutularını bir grup oluşturma.
$connection=mysql_connect ("localhost", "foo", "bar") or die ("I cannot connect to the database.");
$db=mysql_select_db ("database", $connection) or die (mysql_error());
$query = "SELECT type FROM typelist ORDER BY type ASC";
$sql_result = mysql_query($query, $connection) or die (mysql_error());
i=1;
echo "<table valign="top"><tr><td>";
while ($row = mysql_fetch_array($sql_result)) {
$type = $row["type"];
if ($i > 1 && $i % 26 == 0)
echo '</td><td>';
else if ($i)
echo '';
++$i;
echo "<input style='font-size:10px;' name='type[]' type='checkbox' value='$type'><span style='color:#000;'>$type</span></input><br/>";}
echo '</td></tr></table>';
Ben dizi ayrıştırma ve virgül bu kod bloğu ile bir veritabanına metin ayrılmış gibi değerleri terkediyorum.
$allTypes = $_POST['allTypes'];
var_dump($allTypes);
$allStyles = "";
foreach ($type as $style) {
$allTypes .= $style . ", ";
}
$allTypes = substr($allTypes, 0, -2);
It works great. My problem is on the edit record page. I'm generating the list as before, but this time I need to have the check boxes "checked" if that checkbox item had been entered into the database.
Bunu nasıl kod ilk bloğunu değiştirmek için ne yapmalıyım?