Editing Tables [Resolved]
Posted: Mon Aug 26, 2013 3:35 am
Not sure who's the expert on mysql and php, but I'm working on an admin section where I can edit the usernames and such instead of having to edit from database. Below I have something I just threw together really quick. It's showing the username and such but when I update, it's not making the change in the database. Does anyone know anything about this?
The mydata3.php is the same document, so it's only one php file.
Code: Select all
if(isset($_POST['Update'])){
$UpdateQuery = "UPDATE user SET username='$_POST[Username]', WHERE username='$_POST[hidden]'";
mysql_query($UpdateQuery, $con);
};
$sql = "SELECT * FROM user";
$myData = mysql_query($sql,$con);
?>
<tr>
<table border=1>
<th>Username</th>
</tr>
<?php
while($record = mysql_fetch_array($myData)) {
echo "<form action = 'mydata3.php' method=post>";
echo "<tr>";
echo "<td>" . "<input type = text name = Username value =" . $record['username'] . " </td>";
echo "<td>" . "<input type = hidden name = hidden value =" . $record['username'] . " </td>";
echo "<td>" . "<input type = submit name = update value=Update" . " </td>";
echo "</form>";
}
echo "</table>";
mysql_close($con);
;