I'm back again!
This time I have problems getting my form to delete records.
I'm trying to select the record to be deleted with the use of a Select List, and try as I have over the past few hours I cannot make it function.
It's time, I said to myself, to ask for help.
Here's some php code:
And here's the form:
I wonder if you can tell me why clicking the button fails to delete the record for me.
Thanks for looking.
This time I have problems getting my form to delete records.
I'm trying to select the record to be deleted with the use of a Select List, and try as I have over the past few hours I cannot make it function.
It's time, I said to myself, to ask for help.
Here's some php code:
PHP:
<?php $writer = $_SESSION['MM_Username']; //Variable set to select correct Record (below)
mysql_select_db($database_tormented3, $tormented3);
$query_rstAut = "SELECT * FROM authors WHERE username = '$writer'";
$rstAut = mysql_query($query_rstAut, $tormented3) or die(mysql_error());
$row_rstAut = mysql_fetch_assoc($rstAut);
$totalRows_rstAut = mysql_num_rows($rstAut);
mysql_select_db($database_tormented3, $tormented3);
$query_rstFeed = "SELECT * FROM authfeed WHERE username = '$writer' ORDER BY authfeed.pk";
$rstFeed = mysql_query($query_rstFeed, $tormented3) or die(mysql_error());
$row_rstFeed = mysql_fetch_assoc($rstFeed);
$totalRows_rstFeed = mysql_num_rows($rstFeed);
if ((isset($_POST['pk'])) && ($_POST['pk'] != "") && (isset($_POST['form1']))) { //deletion sequence
$deleteSQL = sprintf("DELETE FROM authfeed WHERE pk=%s",
GetSQLValueString($_POST['pk'], "int"));
mysql_select_db($database_tormented3, $tormented3);
$Result1 = mysql_query($deleteSQL, $tormented3) or die(mysql_error());
$deleteGoTo = "list.php";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
?>
And here's the form:
PHP:
<form name="form1" method="POST">
<p> </p>
<p>
<select name="pk" size="1" id="pk">
<?php
do {
?>
<option value="<?php echo $row_rstFeed['pk']?>"<?php if (!(strcmp($row_rstFeed['pk'], $row_rstFeed['pk']))) {echo "SELECTED";} ?>><?php echo $row_rstFeed['pk']?></option>
<?php
} while ($row_rstFeed = mysql_fetch_assoc($rstFeed));
$rows = mysql_num_rows($rstFeed);
if($rows > 0) {
mysql_data_seek($rstFeed, 0);
$row_rstFeed = mysql_fetch_assoc($rstFeed);
}
?>
</select>
<span class="red_text">First - </span> <span class="red_text">Select the number of the comment to be deleted as given on the pubished page. (Please check carefully)</span></p>
<p class="red_text"> Next - Click the Submit button to permenantly delete the comment: </p>
<p>
<input type="submit" name="Submit" value="Submit">
<input name="username" type="hidden" id="username" value="<?php echo "$writer";?>">
</form></p></td>
I wonder if you can tell me why clicking the button fails to delete the record for me.
Thanks for looking.