I retrieve multiple rows from one table and I display them in a grid. For each row I want to be able to change the name and then make one update that updates every row. the grid looks something like this: ...
while ($rowsf=mysql_fetch_assoc($getrows)) {
$namelist=$rowsf['name'];
echo '<input name="nameupdate" type="text" value="'.htmlspecialchars($namelist, ENT_QUOTES).'"/><br>';
}
I currently have the following code, which would work if I had an array. Is it possible to save each $nameupdate in an array?
$nameupdate = $_POST['nameupdate'];
$updateall=$_POST['updateall'];
if ($updateall) {
for($i=0; $i<=$maxpos; $i++) {
mysql_query("update table set name='$nameupdate[$i]' where playlistid=$playlistget and pos=$i");
}
header("Location: mysite.php");
}
What would be the best way to update the rows?