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
Final year project, please point me in the right direction
hi there for my final year project I'm aiming to build a php script shell to use as an expert system
Regarding accessing SQL query issued by any user in Oracle 10g
Hi all,
i want to know the queries issued by various users accessing a database...
form submit at godaddy?
Trying to test form submission at GoDaddy and it does not seem to work. Here's the page...
h
PHP url branch??
Functionally, using PHP, I'm doing a test of login input submitted by a user via an html form in a f
Online Event Ticket Sales
Has anyone wrote a script for online tickets sales?
I have been googling and found lots of th
PHP Array quick help
I need
$_SESSION{'username'} to be like this:
if $_SESSION['username'] = "gay
single page with referrer to show correct page
I have a simple website with a couple of different pages. I would like to be able to in a div tag w
Need some ideas as to how to go about sorting this array...
Here's how the array's are created..
Code: <?php
while ($x = readdir($dp)) {
Is this Safe or Unsafe?
Hi i made a few pages with lots of peoples help now i just want to know if they are safe or not can
On page view, minus credit
Hello all, please, I need a little help with this script. I am charging one credit (credits can be p