I have done this before and for some reason I just can't get it to work this time! I'm pulling my hair out over this! Because there is no errors, it just wont update the database.
Basically I Have a Table with student data in....
ID | IMGNU | Firstname | Surname | FBID
Let's use row 233 for an example.
I can view a specific row by going to view.php?ID=233
Then that works, but now i want to be able to go to edit.php?ID=233 and it should load a form, that already has the info from row 233. I should then be able to edit the data in the fields and submit the form, which would change the information in the database.
Here is what i have already.
edit.php
<?php
mysql_connect('localhost', 'admin', 'passw0rd') or die(mysql_error());
echo "Tick <p>";
mysql_select_db("students") or die(mysql_error());
echo "Tick";
$UID = $_GET['ID'];
$query = mysql_query("SELECT * FROM stokesley_students WHERE id = '$UID'")
or die(mysql_error());
while($row = mysql_fetch_array($query)) {
echo "";
$firstname = $row['firstname'];
$surname = $row['surname'];
$FBID = $row['FBID'];
$IMGNU = $row['IMGNU'];
};
?>
<form action="update.php?ID=<?php echo "$UID" ?>" method="post">
IMGNU: <input type="text" name="ud_img" value="<?php echo "$IMGNU" ?>"><br>
First Name: <input type="text" name="ud_firstname" value="<?php echo "$firstname" ?>"><br>
Last Name: <input type="text" name="ud_surname" value="<?php echo "$surname" ?>"><br>
FB: <input type="text" name="ud_FBID" value="<?php echo "$FBID" ?>"><br>
<input type="Submit">
</form>
And here is update.php
<
?php
$ud_ID = $_GET["ID"];
$ud_firstname = $_POST["ud_firstname"];
$ud_surname = $_POST["ud_surname"];
$ud_FBID = $_POST["ud_FBID"];
$ud_IMG = $_POST["ud_IMG"];
mysql_connect('localhost', 'admin', 'passw0rd') or die(mysql_error());
echo "MySQL Connection Established! <br>";
mysql_select_db("students") or die(mysql_error());
echo "Database Found! <br>";
$query="UPDATE * stokesley_students SET firstname = '$ud_firstname', surname = '$ud_surname',
FBID = '$ud_FBID' WHERE ID ='$ud_IMG'";
mysql_query($query);
echo "<p>Record Updated<p>";
mysql_close();
?>
Any ideas would be much appreciated, maby im just missing something stupid?
Thanks Alex