The title nearly explains itself to be honest. I am trying to change my Delete column from 0 to 1, depending on what player has been selected from my listplayers drop down.
My listPlayers.php file is working 100%. The players are showing up fine in the dropdown. I should add that the error is happening within my $sql variable.
<?php
include 'dbconnect.php';
$sql = "UPDATE players SET Delete = 1 WHERE playersID = $_POST[playersIDHidden]";
if(! mysql_query($sql, $conn))
{
echo "Error " . mysql_error();
}
else
{
if(mysql_affected_rows() != 0)
{
echo $_POST[pName] . " has been deleted <br>";
echo "Person ID: " . $_POST ['playersID'] . "<br>";
echo "Players Name: " . $_POST ['pName'] . "<br>";
echo "Deletion complete";
}
else
{
echo "No records were changed";
}
}
mysql_close($conn);
?>
<form action = "viewPlayers.php" method = "POST" />
<input type = "submit" value = "View Players">
</form>
And finally my listPlayers.php that is showing my players names in the drop down.
<?php
include "dbconnect.php"; //Opening Database Connection
$sql = "SELECT * FROM `players` WHERE `Delete` = 0;";
if (!$result = mysql_query($sql, $conn))
{
die('Error in querying the database' . mysql_error());
}
echo "<br><select name = 'listPersons' id = 'listPersons' onclick = 'populate()'>";
while ($row = mysql_fetch_array($result))
{
$id = $row['playersID'];
$pName = $row['playersName'];
$dob = $row['playersDateOfBirth'];
$dob = date ("d-m-Y", strtotime($dob));
$allText = "$id, $pName, $dob";
echo "<option value = '$allText'> $pName </option>";
}
echo "</select>";
mysql_close($conn);
?>
Sorry for the relatively long post. I am generally able to fix 99% of undefined errors. This one has me lost.
Cheers!