$hostname = 'localhost'; $username = 'root'; $password = 'root'; $dbname = 'fenster'; try { $dbh = new PDO("mysql:host=$hostname;dbname=$dbname", $username, $password); if($_POST['profil']) { $profil = $_POST['profil']; $farbe = $_POST['farbe']; $fenstertyp = $_POST['fenstertyp']; $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = "INSERT INTO bestellen (profil, farbe, fenstertyp) VALUES (:profil, :farbe, :fenstertyp)"; $stmt = $dbh->prepare($sql); $stmt->bindParam(':profil', $profil, PDO::PARAM_STR); $stmt->bindParam(':farbe', $farbe, PDO::PARAM_STR); $stmt->bindParam(':fenstertyp', $fenstertyp, PDO::PARAM_STR); if ($stmt->execute()) { populate_shoutbox(); } } } catch(PDOException $e) { echo $e->getMessage(); } if($_POST['refresh']) { populate_shoutbox(); } function populate_shoutbox() { global $dbh; $sql = "select * from bestellen"; echo '<table width="100%" border="0" align="right" cellpadding="5" cellspacing="0">'; foreach ($dbh->query($sql) as $row) { echo '<tr>'; echo '<td>'; echo '</td>'; echo '<td>'; echo '</td>'; echo '<td>'; echo '</td>'; echo '<td>'; echo '</td>'; echo '</tr>'; echo '<tr>'; echo ''; echo '</tr>'; } echo '</table>'; } if($_POST['id']) { $id=$_POST['id']; $id = mysql_escape_String($id); $sql = "delete from bestellen where id='$id'"; mysql_query( $sql); } ?>
dalej operuje skryptem AJAX w pliku np. div.js
$(function() { $(".usun").click(function() { var id = $(this).attr("id"); var dataString = 'id='+ id ; var parent = $(this).parent(); $.ajax({ type: "POST", url: "dane.php", data: dataString, cache: false, success: function() { if(id % 2) { parent.fadeOut('slow', function() {$(this).remove();}); } else { parent.slideUp('slow', function() {$(this).remove();}); } } }); return false; }); });
i nie chce mi usuwać tego ch...go rekordu...nie wiem co jest grane.... a ma to usuwać bez odświeżania strony dynamicznie...