Im very new to PHP and im wondering how I can create a button to delete a post on my blog system.
My system is as follows;
Blog Page
<?php
include ("includes/includes.php");
$blogPosts = GetBlogPosts();
foreach ($blogPosts as $post)
{
echo "<div class='post'>";
echo "<h2>" . $post->title . "</h2>";
echo "<p>" . $post->description . "</p>";
echo "<span class='footer'>Date: " . $post->date . "</span>";
echo "</div>";
}
?>
Includes File
<?php
include 'blogpost.php';
//MySQL Connection
function GetBlogPosts($inId=null, $inTagId =null)
{
if (!empty($inId))
{
$query = mysql_query("SELECT * FROM news WHERE id = " . $inId . " ORDER BY id DESC");
}
else
{
$query = mysql_query("SELECT * FROM news ORDER BY id DESC");
}
$postArray = array();
while ($row = mysql_fetch_assoc($query))
{
$myPost = new BlogPost($row["id"], $row['title'], $row['description'], $row['descriptionfull'], $row["date"]);
array_push($postArray, $myPost);
}
return $postArray;
}
?>
Any ideas are welcome.
Thank you