Hy,
I`m pretty new in PHP, and I have a little problem,
how can I update data from a mysql table using a grid ?
If I have two ore more records, how can I update them ?
I know how to pull the dat out from the database, but I don`t know hot to put it back.
Thanks
data grid and mysql
Moderator: General Moderators
do you have a field called ID or a field which is unqiue to each record?
if so, put use that...here is a example:
edit.php
if so, put use that...here is a example:
Code: Select all
<?php
$query = mysql_query("select ID, name from table");
while($row = mysql_fetch_array($query))
{
echo "[<a href="edit.php?id=$row[ID]">Edit</a>]$row[name]<br />";
}
?>
?>Code: Select all
<?php
//update
if(isset($_POST[ready]))
{
$update = mysql_query("update table set name='$_POST[name]' where ID =$id limit 1");
echo "UPDATED...";
}
//form
$id = (int)$_GET['id'];
$data = mysql_fetch_array(mysql_query("select name from table where ID = $id"));
echo "<form method=post action="?id=$id">
NAME: <input type="text" value=""><br />
<input type="submit">
<input type=hidden name=ready value=$id>
</form>";
?>