Ok im on the last part of my project before i can make it look pretty
and im stuck!
i need fresh eyes on this
(let me know if there are other mistakes as well there is always room for improvement right!!)
so my whole app works ok except for the last part i want users to be able to edit or update info in mysql table in this case ONLY the last row “Notepad”
users will be able to type any information re: that “cust/account/student/” w/e…
everything works ok but the information is not being updated in the table and i get the following error at the end when trying to update the info
“you have connected successfullyERROR”
Thanks in advance sorry for posting so much code
data
table name=clbacks
final.php
////this part works ok
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
echo "<tr><td>";
echo $row['CustCl'];
echo "</td> <td>";
echo $row['CustInfo'];
echo "</td><td>";
echo $row['CustNumber'];
echo "</td><td>";
echo $row['CSR'];
echo "</td><td>";
echo $row['Time'];
echo "</td><td>";
echo $row['ID'];
echo "</td><td>";
echo $row['Notepad'];
echo "</td><td>";
echo "<a href=\\"update2.php?id=" . $row['ID'] . "\\">Update Notepad</a>";
echo "</td></tr>";
}
echo "</table>";
} // end of main if statement
?>
update2.php
<?php
//connect to the database
include('connect.php');
// get value of id that sent from address bar
$id=$_GET['id'];
// Retrieve data from database
$sql="SELECT * FROM clbacks WHERE id='$id'";
$result=mysql_query($sql);
$rows=mysql_fetch_array($result);
?>
<table width="400" border="1" cellspacing="1" cellpadding="0">
<tr>
<form name="form1" method="post" action="update_ac.php">
<td>
<table width="100%" border="1" cellspacing="1" cellpadding="0">
<tr>
<td> </td>
<td colspan="3"><strong>Update Notepad</strong> </td>
</tr>
<tr>
<td align="center"> </td>
<td align="center"><strong>Notepad</strong></td>
</tr>
<tr>
<td> </td>
<td align="center"><input name="name" type="text" id="name" value="<? echo $rows['Notepad']; ?>"></td>
<tr>
<td><input name="id" type="hidden" id="id" value="<? echo $rows['id']; ?>"></td>
<td align="center"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
<?
// close connection
mysql_close();
?>
update_ac.php
<?php
//connect to the database
include('connect.php');
// update data in mysql database
$sql="UPDATE clbacks SET Notepad='$Notepad' WHERE id='$id'";
$result=mysql_query($sql);
// if successfully updated.
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='final.php'>View result</a>";
}
else {
echo "ERROR";
}
?>