Hallo zusammen,
ich habe folgendes geschrieben.
Und mein Problem ist das erstens kein Update gemacht wird und das ich eigentlich die Funktion so sein soll wenn der eine der Checkboxen aktiviert in der Datenbank eine 1 oder eine 0 stehen soll.
Wo kann der Fehler sein.
Abfrage:
Code:
<?php
/*Verbindung aufnehemen*/
mysql_connect("localhost",xxx,xxx);
/*Datenbank auswählen*/
mysql_select_db("xxx");
?>
<?php $sql = "SELECT * FROM sprache_h_code_bul";
$abfrageergebnis = mysql_query( $sql ); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>jQuery UI Button - Checkboxes</title>
<link rel="stylesheet" href="css/jquery.ui.all.css">
<script src="js/jquery-1.6.2.js"></script>
<script src="js/jquery.ui.core.js"></script>
<script src="js/jquery.ui.widget.js"></script>
<script src="js/jquery.ui.button.js"></script>
<link rel="stylesheet" href="css/demos.css">
<script type="text/javascript">
// When the document is ready set up our sortable with it's inherant function(s)
$(document).ready(function() {
$("#format").buttonset({
handle : '.handle',
update : function () {
var order = $('#format').buttonset('serialize');
$("#info").load("checkbox.update.php?"+order);
}
});
});
</script>
<style>
#format { margin-top: 2em; }
</style>
</head>
<body>
<div class="demo">
<div id="format">
<?php
while ($datensatz = mysql_fetch_array( $abfrageergebnis )) {
echo'
<input type="checkbox" id="catID_' .htmlspecialchars( $datensatz['id'] ). '" /> <label for="catID_' .htmlspecialchars( $datensatz['id'] ). '"><strong>' .( $datensatz['h_code'] ). '</strong></label>';
}
?>
</div>
</div><!-- End demo -->
</body>
</html>
Update Funktion
Code:
<?php
/*Verbindung aufnehemen*/
mysql_connect("localhost",xxx,xxx);
/*Datenbank auswählen*/
mysql_select_db("xxxx");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Checkbox Update</title>
</head>
<body>
<?php
foreach ($_GET['catID'] as $position => $item) :
$result = mysql_query("UPDATE sprache_h_code_bul SET aktiv= '$position' WHERE id = '$item'");
if (!$result) {
die('Ungültige Abfrage: ' . mysql_error());
}
endforeach;
?>
</body>
</html>