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
date("now") prints out wrong date ?
Hi Guys
Anyone know why and how I can fix it ?
Get last modified date of web page
Hai All,
In php how can i get last modified date of a give web page . I have tried to g
Why will this program not run if the variables are not global?
Hey guys I have a kind of perplexing situation that is probably simple, but I can't seem to understa
Rss feed question
Hi
My blog and my website are different. Am i able to take my rss feed
from my blog and p
Can't find the problem (no error message)!
OK, here's the deal. This code is really weirdly formatted (sorry!) and hard to understand, so I'm g
reading xml faster than DB call?
I am trying to optimize a high traffic website, and I enabled a feature where there are three photos
Redirect not working after making a POST/GET
Hi Everyone,
I am a novice in PHP. Here I have 2 pages, one page with a textbox and button an
PHP friend keyword equivalent
is there a PHP equivalent for the C++ friend keyword?
PRotect my POST DATA... FROM HTML ATTACKS
I need to like let's say
If a user submit's his Prayer and he put's <meta refresh stuf
DateTimeZone::listIdentifiers headache
http://php.net/manual/en/datetimezone.listidentifiers.php
So the documentation states tha