<?php

require_once "functions.php";
require_once "tablefunctions.php";
if (isset($_GET["delete"])) {
    echo "Kustutame id " . $_GET["delete"];
    deletePosts($_GET["delete"]);
}
if (isset($_POST["save"])) {
    updatePosts($_POST["id"], $_POST["post"]);
}
$keyword = "";
if (isset($_GET["keyword"])) {
    //otsin
    $keyword = $_GET["keyword"];
    $array_of_posts = getPostsData($keyword);
} else {
    $array_of_posts = getPostsData();
}
?>
<a href="data.php">Lisa uus postitus</a>
<h2>Tabel</h2>
<form action="poststable.php" method="get" >
	<input type="search" name="keyword" value="<?php 
echo $keyword;
?>
" >
	<input type="submit">
</form>

<table border=1 >
Пример #2
0
    echo "<td><a href='../post.php?p_id={$post_id}'>View Post</a></td>";
    echo "<td><a href='posts.php?source=edit_post&p_id={$post_id}'>Edit</a></td>";
    //                        echo "<td><a onClick=\" javascript: return confirm('Are You Sure?'); \" href='posts.php?delete={$post_id}'>Delete</a></td>";
    echo "<td><a rel='{$post_id}' href='javascript:void(0)' class='delete_link'>Delete</a></td>";
    echo "</tr>";
}
?>


                </tbody>
            </table>
</form>

 <?php 
if (isset($_GET['delete'])) {
    deletePosts();
}
?>


<script>

$(document).ready(function(){


$(".delete_link").on('click', function(){

    var id = $(this).attr("rel");

    var delete_url = "posts.php?delete="+ id + " ";