<script type="text/javascript">
$(document).ready(function() {
var content = $('.main');
$('input.button').click(function(e) {
var nr = $(this).attr('id');
var image = $('#image'+nr).val();
var title = $('#title'+nr).val();
var tresc = $('#tresc'+nr).val();
var link = $('#link'+nr).val();
tresc=tresc.replace(/(\r\n|\n\r|\r|\n)/g, "<br>");
var dataString = 'image='+ image + '&title=' + title + '&tresc=' + tresc + '&link=' + link + '&nr=' + nr;
if(!confirm('Czy na pewno poprawić wpis?')){
return false;
}
$.ajax({
url: ('edit.php'),
data: dataString,
success: function(obj){
content.html(obj);
}
});
e.preventDefault();
});
});
</script>
<?php
require_once ('../../functions.php');
connect($adres, $user, $pass, $baza);
if ($_GET['image']!="" && $_GET['title']!="" && $_GET['tresc']!="" && $_GET['link']!="") {
$image = $_GET['image'];
$title = $_GET['title'];
$tresc = $_GET['tresc'];
$link = $_GET['link'];
$nr= $_GET['nr'];
mysql_query("UPDATE example SET image='$image', title='$title', tresc='$tresc', link='$link' WHERE id='$nr'"); }
$zapytanie = "SELECT * FROM `example` ";
echo "<div style='border-bottom:1px solid; width:500px;margin:10px;'> <input type='text' value='".$row[0]."' class='edit' ><br>
<input type='text' value='".$row[1]."' class='edit' id='image".$row[0]."'><br>
<input type='text' value='".$row[2]."' class='edit' id='title".$row[0]."'><br>
<textarea class='edit' id='tresc".$row[0]."'>".preg_replace('#<br\s*/?>#i', "\n", $row[3])."</textarea><br> <input type='text' value='".$row[4]."' class='edit' id='link".$row[0]."'>
<input type='button' value='Edit' class='button' id='".$row[0]."'>
</div>" ;
};
koniec($adres, $user, $pass);
?>