ok i have a list of data that gets displayed in listbox...
i want tht when i select any value in tht listbox and click on rename it should rename tht in the database with the value i provide in the text box.
i m able to get the values listed in list box...but its not renaming it .
here's my code
plz tell where i m going wrong...and what i need to change where
i want tht when i select any value in tht listbox and click on rename it should rename tht in the database with the value i provide in the text box.
i m able to get the values listed in list box...but its not renaming it .
here's my code
Code:
<body>
<?php
$genre_name = $_POST['genre'];
$genrename = 'genrename';
$genrevalue = array();
$genre_value = $_POST['genrename'];
$query_name = " SELECT image_category.genre FROM image_category ";
$result = mysql_query($query_name);
confirm_query($result);
$genrename_list[]=" ";
while ($record = mysql_fetch_assoc($result)) {
$genrename_list[] = $record['genre'] ;
}
?>
<?
//-----------Rename genre in database ---------------------
if (isset($_POST['rename_genre'])) {
$query = "UPDATE image_category
SET image_category.genre = '$genre_name'
WHERE image_category.genre = '{$genrename_list[$genre_value]'";
$result1 = mysql_query($query, $connection);
if ($result1) {
$message = "new genre has been renamed";
}
else {
$message = "new genre could not be renamed";
}
}
?>
<td id="page">
<form action="genre_rename.php" method="post">
<table>
<td><br>
<select name="genrename" maxlength="30">
//-----------displays genre from database ---------------------
<?php
// Loops through the $status_list array
foreach ($genrename_list as $value => $option)
{
// Sets an attribute to show the chosen status as selected
$selected = ($genre_value == $value) ? ' selected="selected"' : '';
//$status = (isset($_get['status'])) ? $_get['status'] : "";
// Builds an option for each acceptable status
echo '<option value="'.$value.'"'.$selected.'>'.$option.'</option>';
// echo '<option value="'.$value.'"'.$status.'>'.$option.'</option>';
}
?>
</select> </td>
<tr>
<td>Genre</td>
<td><input type="text" name="genre" maxlength="20" value="<?php echo htmlentities($genre_name); ?>" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="rename_genre" value="rename_genre" /></td>
</tr>
</table>
</form>
</td>
</body>
plz tell where i m going wrong...and what i need to change where
Comment