I'm trying to print all of the rows from a table in my database and then provide a link after each one to link to a delete script (deleteNews1.php)
I keep getting errors with this code...
<?php
$mysqli = mysqli_connect("localhost", "root", "Dee1987!", "anml");
if(mysqli_connect_errno()){
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}else{
//Get all records in all columns from table and put it in $result.
$result=mysql_query("select * from tblnews");
/*Split records in $result by table rows and put them in $row.
Make it looping by while statement. */
while($row=mysql_fetch_assoc($result)){
// Output
echo "ID :$row['news_id'] <br/>";
echo "Name :$row['news_name']<br/>";
echo "Email :$row['news_date']<br/>";
echo "Tel :$row['news_location']<br/>";
// Add a link with a parameter(id) and it's value. This for delete record at delete.php
echo '<a href="deleteNews1.php?id='.$row['news_id'].'">Delete</a>';
}
mysql_close($mysqli);
?>
deleteNew1.php:
<?PHP
$mysqli = mysqli_connect("localhost", "root", "Dee1987!", "anml");
$time = time();
$date = date("jS F Y", $time);
$id=$_GET['id'];
if (mysqli_connect_errno()){
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}else{
$id=$_GET['id'];
// Do delete statement.
mysql_query("delete from tblnews where news_id='$id'");
// Close database connection
mysql_close();
// Redirect to deleteNews.php.
header("location:deleteNews.php"); }
?>
Any body any ideas? Much appreciated as i need to get this figured asap!
Thanks
Dee