Where am I going wrong
Posted on
16th Feb 2014 07:03 pm by
admin
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??
No comments posted yet
Your Answer:
Login to answer
154 19
Other forums
MII Trends - add data onto chart object
Hello,
Can anyone please provide some thoughts on my current requirement:
its pretty
pass form variables straight to email, no database required?
hello all,
im working on this form...
http://www.adobedayevents.com/project_request/pr
How to get variable value on next page
Hello friends
i am working on payentry page ..there i have this code.........
first few characters only
hi, does anyone know how to use PHP to take the first few words of a text and limit them? i have see
if description does not contain the following words
Hello everyone,
I am parsing a MS Excel (.xls) file and adding it's content to a mySQL databa
my sql select id and then update problem.
I need to select some auto incremented ids out of a database and then use those id in a where statem
Amend code to allow multiple attachments
Hi
I have a php page that allows the user to browse to a file (image) then sumbit, the confi
delete comma
HI,
How to delete "," at the end of the string.
Code: $match = 2009/02/03/a2corr
Troubles with a spider class
I am building a spider that will crawl through random whitepages (eg. anywho.com, switchboard.com, w
Creating a function
Basically i wanna put all this code in a seperate file
Code: <?php