record not getting deleted
Posted: Sat Apr 25, 2009 4:15 am
i have a listbox with lists which is populated from the database now i want tht when i select a particular record in tht listbox and then click on remove button it shoudl remove tht record from database...but it doesnt it just shows me the msg "genre cud not be deleted and Undefined index: genrename at line 20.
alos i want tht on deletetion the fresh list be populated in the listbox.
plz advice
here's my code
alos i want tht on deletetion the fresh list be populated in the listbox.
plz advice
here's my code
Code: Select all
<?php
$genrename = 'genrename';
$genrevalue = array();
$query_name = "SELECT image_category.genre FROM image_category ";
$result = mysql_query($query_name);
confirm_query($result);
?>
<?php
$genre_select = $_POST['genrename'];
//-----------remove genre form database ---------------------
if (isset($_POST['remove_genre'])) {
$query = "DELETE * FROM image_category WHERE image_category.genre LIKE '%$genre_select%'";
$result = mysql_query($query, $connection);
if ($result) {
$message = " genre has been removed from the list";
}
else { $message = " genre could not be removed from the list";}
}
?>
<td id="page">
<?php if (!empty($message)) {echo "<p class=\"message\">" . $message . "</p>";} ?>
<form action="genre_remove.php" method="post">
<table>
<div style="position: absolute; width: 100px; height: 32px; z-index: 1; left: 225px; top: 5px" id="layer1">
<td><INPUT TYPE = "hidden" VALUE = "" NAME = "genretitle"><br>
<select name="genrename" maxlength="30">
<?php
//-----------displays genre from database ---------------------
while ($record = mysql_fetch_assoc($result)) {
while (list($genrename, $genrevalue) = each ($record)) {
echo '<option>'.htmlentities($genrevalue).'</option>';
}
echo "<BR>";
}
?>
</select> </td>
</div>
<tr>
<td colspan="2"><input type="submit" name="remove_genre" value="remove_genre" /></td>
</tr>
</table>
</form>
</td>
</body>