Hi i am having a problem updating records in mysql database. I am displaying my results, one of the fields is a new textarea for adding notes. I am trying to save this information but there seems to be a problem passing on the 'pid' as it is blank.
Here is my code:
mysql_connect("$host", "root", "root")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$pid = $_GET['pid'];
$sql = "SELECT * FROM reff WHERE `pid` = '$pid'";
$result = mysql_query($sql) or die(mysql-error());
$row = mysql_fetch_assoc($result);
echo "<table border=\"1\" align=\"center\">";
echo "<tr><th>ID</th>";
echo "<td>";
echo $row['pid'];
echo "</td>";
echo "<tr><th>Make</th>";
echo "<td>";
echo $row['make'];
echo "</td>";
echo "<tr><th>Model</th>";
echo "<td>";
echo $row['model'];
echo "</td>";
echo "<tr><th>Registration</th>";
echo "<td>";
echo $row['registration'];
echo "</td>";
echo "<tr><th>Image</th>";
echo "<td>";
echo "<img src='upload/".$row['image']."' width='250' height='250'/>";
echo "</td>";
echo "<tr><th>Image</th>";
echo "<td>";
echo "<img src='upload/".$row['image2']."' width='250' height='250'/>";
echo "</td>";
echo "<tr><th>Image</th>";
echo "<td>";
echo "<img src='upload/".$row['image3']."' width='250' height='250'/>";
echo "</td>";
echo "<tr><th>Image</th>";
echo "<td>";
echo "<img src='upload/".$row['image4']."' width='250' height='250'/>";
echo "</td>";
echo "<tr><th>Damage Report</th>";
echo "<td>";
echo "<a href='upload/".$row['report']."' target='_blank'>Click Here to view damage report</a>";
echo "</td>";
echo "<tr><th>Notes on Caes</th>";
echo "<td>";
echo "<textarea cols=80 rows=10 name=ymynotes></textarea>";
echo "</td>";
echo "<tr><th></th>";
echo "<td>";
echo "<button onclick=\"window.location.href='save.php?pid=".$row['pid']."'\">Save</button>";
echo "</td>";
?>
Here is my code for adding the information into the database:
// Connect to server and select databse.
mysql_connect("$host", "root", "root")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$pid = $_GET['pid'];
$mynotes=$_POST['mynotes'];
$sql = "UPDATE reff SET notes = '" . $_POST['mytitle'] . "'WHERE pid='" . $_POST['pid'] . "'";
mysql_query($sql) or die(mysql_error());
echo '<br />Query was:'.$sql;
?>