How do I remove a row from a table based on a variable. The database has three tables. Depending on the variable, I would like for the php script to select the proper table and delete the the entire row.
This is what I did, but I get a syntax error:
<?php
$dbHost = "localhost";
$dbUser = "";
$dbPass = "";
$link = @mysql_connect($dbHost, $dbUser, $dbPass);
$dbName = "players";
$db = mysql_select_db($dbName, $link) or die("couldn't select database");
$status = $_POST["status"];
$userid = $_POST["userid"];
if ($status = "successful");
{
$query = "DROP FROM players WHERE userid = $userid";
mysql_query($query,$link)or die(mysql_error());
}
?>
the tables are: football, soccer, baseball.
Based on the received variable the script should be able to decide which table to delete from according to the $userid.
I am rahter new at this. I have a book, but unfortunately it does not answer questions. 🙁
Please help if you can.