Hello all. I am currently trying to make a admin panel for a commenting script. I am learning php so things are difficult sometimes as one would know. My question is with my code below i have to click the delete button twice in order for the item to delete, I believe its the way i have it scripted, least i got that far on my own i guess. But this is making me crazy,lol … any help with this code is truly appreciated, Thanks
/*
id |
qazi id |
name |
url |
email |
description |
date |
delete |
<?php
/*** mysql hostname ***/
$hostname = 'mine';
/*** mysql username ***/
$username = 'mine';
/*** mysql password ***/
$password = 'mine';
/*** mysql database name ***/
$dbname = 'mine';
/*** create a new mysqli object with default database***/
$mysqli = @new mysqli($hostname, $username, $password, $dbname);
/* check connection */
if(!mysqli_connect_errno())
{
/*** if we are successful ***/
echo 'Welcome to Adimn panel
';
/*** our SELECT query ***/
$sql = "SELECT id, qazi_id, name, url, email, description, date FROM comments";
/*** prepare statement ***/
if($stmt = $mysqli->prepare($sql))
{
/*** execute our SQL query ***/
$stmt->execute();
/*** bind the results ***/
$stmt->bind_result($id, $qazi, $name, $url, $email, $description, $date);
/*** loop over the result set ***/
while ($stmt->fetch())
{
/*** echo our table rows ***/
echo '
'.$id.' |
'.$qazi.' |
'.$name.'; |
'.$url.' |
'.$email.' |
'.$description.' |
'.$date.' |
|
';
}
}
/*** close connection ***/
$mysqli->close();
}
else
{
/*** if we are unable to connect ***/
echo 'Unable to connect';
exit();
}
?>
<?php
$con=mysqli_connect("mysql.1freehosting.com","u715455357_clb","dmb31508","u715455357_talk");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$which = $_REQUEST['name'] ;
echo "
Delete =
";
mysqli_query($con,“DELETE FROM comments WHERE id=’$which’”);
?>
table, td, th
{
border:1px solid green;
}
th
{
background-color:green;
color:white;
}
*/