Hello !!
Question related to mysql delete tag
I have a table in php file
id name type option
1 alex student delete
2 tea teacher delete
I want delete one of this , but is not working the delete option
this the php file where is the table
[php]
$db = mysql_connect(‘localhost’, ‘—’, ‘—’) or
die (‘Error in the conection.’);
mysql_select_db(‘users’, $db) or die(mysql_error($db));
$query = ‘SELECT id,name, type FROM data’;
$result = mysql_query($query, $db) or die(mysql_error($db));
echo ‘
id | name | type | opction |
---|---|---|---|
’. $fila[“id”] . ‘ | ’;’. $fila[“name”] . ‘ | ’;’ .$fila[“type”] . ‘ | ’;<a href=“delete.php?id=$fila[“id”]”>Delete | ’;
[/php]
this is the delete php
[php]
<?php $host="localhost"; // Host name $username="---"; // Mysql username $password="---"; // Mysql password $db_name="users"; // Database name $tbl_name="data"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // get value of id that sent from address bar $id=$_GET['id']; // Delete data in mysql from row that has this id $sql="DELETE FROM $tbl_name WHERE id='$id'"; $result=mysql_query($sql); // if successfully deleted if($result){ echo "Delete completed "; echo ""; echo "Return"; } else { echo "ERROR"; } // close connection mysql_close(); ?>
[/php]
Its not working I choose the delete option in the table and then says “delete completed” I return to the view where is the table and the data is still there.
So, whats wrong??
I wonder if its this line
echo ‘
thanks