I am trying to add a form to my forum to update values in my database. The database contains two columns, "name" and "money". The form is generated in a basic FOR loop as follows:
<?php for ($i =0; $i < 6; $i++) {?>
<?php echo $cash[$i]['name']; ?>
<input name="value<?php echo $i; ?>" value = "<?php echo $cash[$i]['money']; ?>">
<?php } ?>
On pressing submit, another php file is called where I'd like to update the "money" value in another FOR loop. The line I imagine working looks like this:
Code:
$sql = "UPDATE cash_amt SET money = $value"$i" WHERE name = '$cash[$i]['name']'";
My problem is not understanding the PHP code - where I put $value"$i" above I'd like it to cycle through $value0, $value1, $value2, etc. as assigned in the first FOR loop. Can anyone help me with the correct code?
Whether this is the most efficient way to do this - I don't know. Any suggestions welcome.
TIA.