Re: rename values in dropdown box
Posted: Mon May 04, 2009 9:18 pm
ok i corrected the errors u mentioned but its still not executing the the code its only refreshing the page
Code: Select all
<?php require_once("d:/wamp/www/php_stockphotos/includes/session.php"); ?>
<?php require_once("d:/wamp/www/php_stockphotos/includes/connection.php"); ?>
<?php require_once("d:/wamp/www/php_stockphotos/includes/constants.php"); ?>
<body>
<?php
$genre_name = $_POST['genre'];
$genrename = 'genrename';
$genrevalue = array();
$genrename_list = 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'])) {
echo $genre_name;
echo $genrename_list[$genre_value];
if ($genre_name!=""){
$query = "UPDATE image_category
SET image_category.genre = '$genre_name'
WHERE image_category.genre = '{$genrename_list[$genre_value]}'";
$result1 = mysql_query($query);
if ($result1) {
$message = "new genre has been renamed";
}
else {
$message = "new genre could not be renamed";
}
}
}
else
{ $message = " You have left the text box empty....enter valid name to rename the selected ";}
?>
<td = "page">
<form action="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"' : '';
// Builds an option for each acceptable status
echo '<option value="'.$value.'"'.$selected.'>'.$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>