PDA

View Full Version : update database via dropdowns



pkcidstudio
04-16-2007, 09:46 PM
I would like to update my database via a drop down field. I am having trouble calling to the sql query the selected title from the drop down.
index.php
<!-- delete Title -->
<?php
if (isset($_POST["deleteTitle"]))
{
$row = mysql_query("UPDATE pr_mngmnt_manual SET titlehide= '1' WHERE title='$br' ");
}
?>
<form action="<?=$PHP_SELF?>" method="post">
<p><b>Delete Title:</b><br>
<?php
//Select title from a drop down, and allow title deletion (The titlehide flag is set to 1)
include ('query/deleteTitleQuery.php');
?>
<input type="submit" name="deleteTitle" value="Submit">
</p>
</form>
deleteTitleQuery.php


<?php
$query = "SELECT DISTINCT title FROM pr_mngmnt_manual WHERE titlehide='0' ORDER BY title";
$result = mysql_query($query) or die("Invalid query: $sql");
if(mysql_num_rows($result) == 0)
echo "No locations exist";
else
{
echo "<select name=title>";
while($br = mysql_fetch_array($result))
{
//get branch id and branch name into the list
echo "<option value={$br["title"]}>{$br["title"]}</option>";
}
echo "</select>";
}
?>