Been trying to work this out for hours
I have two tables called 'Genres' and 'Films'. Genres contains two columns 'Genre_id' and 'Genre_Name'. Films contains a load of columns, the most important being 'Title', 'Year', Director', 'Genres'. Now im trying to create a page where the user can edit a film in the 'Films' table. I want this form to already be populated with the existing values which the user can then delete and enter new ones. Heres the code:
Code:
<?
include 'connect.php';
$FilmID= $_GET['id'];
$result = mysql_query("SELECT Films.*, Genres.Genre_id, Genres.Genre_Name FROM Films INNER JOIN Genres ON Films.Genres = Genres.Genre_id WHERE Films.Film_id = $FilmID" ,$linkme) or die ('Error: '.mysql_error ());
$row = mysql_fetch_array($result);
$current_Genre = $row['Genre_Name'];
$current_Genre_id = $row['Genre_id'];
?>
<form method="post" action="update2.php?id=<? echo $FilmID ?>">
<table>
<tr>
<td>Title</td>
<td><input name = "Title" value="<? echo $row['Title'] ?>" type="text" /></td>
</tr>
<tr>
<td>Year</td>
<td><input name = "Year" value="<? echo $row['Year'] ?>" type="text" /></td>
</tr>
<tr>
<td>Director</td>
<td><input name = "Director" value="<? echo $row['Director'] ?>" type="text" /></td>
</tr>
<tr><td>
Genre:</td><td> <select name="Genre">
<option value = "<?php echo $current_Genre_id ?>"> <? echo $current_Genre ?> </option>
<?
$result = mysql_query("SELECT * FROM Genres",$linkme) or die ('Error: '.mysql_error ());
while($row = mysql_fetch_array($result));
{ ?>
<option value = "<?php echo $row['Genre_id'] ?>"> <? echo $row['Genre_Name'] ?> </option>
<? } ?>
</select></td>
</tr>
</table>
<input name="Update" type="submit" value="Update" />
</form>
<?
include 'close.php';
?>
<a href = "../admin.php">Back</a>
and heres the second page that actually changes the values:
Code:
<?
include 'connect.php';
$Title = $_REQUEST["Title"];
$Year = $_REQUEST["Year"];
$Director = $_REQUEST["Director"];
$Genre = $_REQUEST["Genre"];
$FilmID = $_GET['id'];
$result = mysql_query("UPDATE Films SET Title = '$Title' , Year = '$Year', Director ='$Director', Genre ='$Genre' WHERE Film_id = '$FilmID'",$linkme);
include 'close.php';
?>
Record Updated<br />
<a href = "../admin.php">Back</a>
There are no errors, the values just dont show up in the form, Where am I going wrong??
PHP & Java
Hello,can PHP code be used inside java code?Code: <SCRIPT LANGUAGE="JavaScript">OpenWindow.document.write("<?php echo NotWorking;
Saving data from a form into a file
Hey everybody,Sorry, I am really new to PHP coding and such but a project kind of got thrust on me. I need to create a a form for people to input some information and then be able to collect the
Working with popups and such in a class
I've recently started building my applications completely enclosed in classes. I like the fact that I can base everything off one root and work with that, but I'm having a problem with popups
Problem in String replace program's output
Hi all,
How to give the privillege for triggers?
Hi,
Guixt issue
Hello all,
Inserting into MySQL Newbie
Hi ive got a slight problem where ive made a simple web form where the customer inserts the ammount of tickets and then enters their personal details... then this form does the post method and it then
GET vs SUBMIT Button to show sections on one index.php page?
Just curious if one of these ways is better (i.e. more efficient) than the other. I have an index.php page where there is a menu across the top with 5 choices. For example, HOME | MONKEYS | CATS |
Add_Months not Easy to Understand
Oracle is number 1, very fast and very easy. But....
database design
Hi,I got a page which allow candidate to type in their previous working experience,I let user to choose the start date and end date and then system will automatically calculate the total experience in