Hi all, I'm new and I currently am developing a website on fishing fred's fishing. The site is an experiment for a portfolio ect. There is a feature, the guestbook. The Guestbook is managed by a MySQL database and the PHP is responsible for creating and echoing the data. I would like it if i could remove a comment by having a cookie and clicking an image to remove a comment much like a delete button. The code below shows what I have written:
//Connecting to the database
$connect = mysql_connect("localhost","***","***")or die("Error Connecting.");
mysql_select_db("150742")or die("Error Selecting.");//selecting the data
//query for everything
$queryget = mysql_query("SELECT * FROM Guestbook") or die ("Error with query");
//using $row as an array for all of the data
while($row = mysql_fetch_assoc($queryget))
{
if($admin=="Yes"){//checking the user administrator privilages
$name =$row['name'];
$message =$row['message'];
$date =$row['date'];
$time =$row['time'];
$id =$row['id'];
strip_tags($message);//variables to collect the data
echo"<hr/><p id='date'>$date $time</p><img src='images/delbutton.jpg' onClick=function delete()/><p id='post'> $name<br/>".strip_tags($message)."</p>";//echos each message in the database
}else{//normal nonadmin comments
$name =$row['name'];
$message =$row['message'];
$date =$row['date'];
$time =$row['time'];
$id =$row['id'];
strip_tags($message);
echo"<hr/><p id='date'>$date $time</p><p id='post'> $name<br/>".strip_tags($message)."</p>";//echos each message in the database
};
};