I need to iterate through a bunch of dynamically generated fields, but this does not work:
$population_density = $_POST['$current_location_id'];
I have a list of places with their population on one page; I need to make sure that you can update them right away. Therefore, I called the field names dynamically matching location_id. When the message is sent, I need to go through them like this, but it looks like you cannot put a variable in the message.
for ( $y_count = 1 ; $y_count <= $zone_height; $y_count++ ) { for ( $x_count = 1 ; $x_count <= $zone_width; $x_count++ ) { $result = mysql_query("SELECT * FROM locations WHERE location_zone='$zone_id' AND x_location='$x_count' AND y_location='$y_count' "); $current_location = mysql_fetch_array( $result ); $current_location_id = $current_location['ID']; $population_density = $_POST['$current_location_id']; $result = mysql_query("UPDATE locations SET population_density='$population_density' WHERE ID='$current_location_id' "); } }
Is it possible to put a variable inside $ _POST []? If not, how do I need to update dynamically generated fields?
Brien source share