I have a landing page that displays movies and people. I can add, edit, or delete. I’m trying to edit the people. I can get the form to display but I’m having a hard time getting the changes to process. Here is my code…
<?php
require_once (‘dbconnection.php’);
$query = “SELECT * FROM people”;
$result = mysql_query($query) or die (mysql_error());
//compare id to name
//array of id and names
while ($row = mysql_fetch_array($result))
{
$people[$row[‘people_id’]] = $row [‘people_fullname’];
}
//either populate fields from db or display empty fields
switch ($_GET[‘action’])
{
case “edit”:
$q = “SELECT * FROM people
WHERE people_id = ‘”.$
$r = mysql_query($q) or die (mysql_error());
$row1 = mysql_fetch_array($r);
$people_fullname = $row1[‘people_fullname’];
$people_isactor = $row1[‘people_isactor’];
$people_isdirector = $row1[‘people_isdirector’];
break;
default:
$people_fullname = “”;
$people_isactor = “”;
$people_isdirector = “”;
break;
}
?>
<html>
<head>
<title><?php echo $_GET[‘action’];?>people</title>
<style type = “text/css”>
TD{color:#353535; font-family:verdana}
TR{color:#FFFFFF; font-family:verdana; background-color:#336699}
</style>
</head>
<body>
<center>1 = yes 0 = No</center>
<form action=”commit.php?action=
<?php echo $
<?php echo $_GET[‘id’];?>” method =”post”>
<table border=”0″ width=”750″ cellspacing=”1″ cellpadding=”3″ bgcolor=”#353535″ align=”center”>
<tr>
<td bgcolor=”#FFFFFF” width=”30%”>Person Name</td>
<td bgcolor=”#FFFFFF” width=”70%”>
<input type=”text” name=”people_fullname”
value=”<?php echo $people_fullname ?>”>
</td>
</tr>
<tr>
<td bgcolor=”#FFFFFF”>Actor</td>
<td bgcolor=”#FFFFFF”>
<select name=”people_isactor” style=”width:150px”>
<option value=”yes”>Yes</option>
<option value=”no”>No</option>
<?php
if ($_POST[‘people_isactor’] == “yes”)
{
$people_isactor = 1;
}
else
{
$people_isdirector = 0;
}
?>
</select>
</td>
</tr>
<tr>
<td bgcolor=”#FFFFFF” colspan=”2″ align=”center”>
<input type=”submit” name=”SUBMIT” value=”<?php
echo $_GET[‘action’];?>”>
</td>
</tr>
</table>
</form>
</body>
</html>
I having trouble with the if statment after the <select> No matter what I choose in the drop down box the if statement always returns false.
I store the peole in my database. The first person may be an actor so i set the actor field to 1 and director field to 0. Right now I’m focusing on the actor portion and then I’ll do the director.