I have a table in MySQL that I am able to edit through PHP but only one row at a time. My client is wanting to be able to edit all the data at one time. There are not many rows but each row has multiple fields. So I need to be able to edit all the rows at one time. Displaying all data in a editable format is no problem, but when it generates I already have the name listed:
[code=php]
while ($row = mysql_fetch_array($result)) {
echo “<tr align=’center’>”;
echo “<td>”, $row[‘name’], “</td>”;
echo “<td><input type=’text’ value='”, $row[‘d_e’], “‘ size=’10’ name=’d’ /></td>”;
echo “<td><input type=’text’ value='”, $row[‘c’], “‘ size=’10’ name=’c’ /></td>”;
echo “<td><input type=’text’ value='”, $row[‘b’], “‘size=’10’ name=’b’ /></td>”;
echo “<td><input type=’text’ value='”, $row[‘a’], “‘ size=’10’ name=’a’ /></td>”;
echo “</tr>”;
}
Then the update looks like this:
[code=php]
$id = $_GET[“id”];
$a = $_POST[“a”];
$b = $_POST[“b”];
$c = $_POST[“c”];
$d = $_POST[“d”];
$query = “UPDATE rates SET a = ‘{$a}’, b = ‘{$b}, c = ‘{$c}’, d_e = ‘{$d}’ WHERE id = ‘{$id}’ “;
The problem should be obvious. Each different row will have different data but the name will be the same so it would confuse the database. Any help on what I can do differently.