php - How do you use a variable in a $_POST[] -


I have to walk again through the bunch of dynamically generated fields, but it does not work:

  $ population_activity = $ _POST ['$ current_location_id'];  

I have a list of places with populations on one page; I need to make it so that you can update many of them once. That's why I made the field names dynamically in accordance with location_id when the post is submitted, I have to run again as soon as they are, but it seems that you can not put a variable in a post. ($ X_count = 1; $ x_count & lt; = $ zone_width; $ x_count ++) {$ for yolkount ($ y_count = 1; $ y_count & lt; = $ zone_height; $ y_count ++) for result

= Mysql_query ("SELECT * from location where location_join = '$ region_id' and x_location = '$ x_count' and y_location = '$ y_count'"); $ Current_location = mysql_fetch_array ($ result); $ Current_location_id = $ current_space ['id']; $ Population_sableness = $ _POST ['$ current_location_id']; $ Result = mysql_query ("update location SET population_number = '$ density of population' where id = '$ current_location_id'"); }}

What can put a variable within $ _POST []? If not, how should I go about updating a dynamically-generated field?

Use it without single quotation marks: < $ current_location_id] < / Pre>

The value of $ current_location_id is now used as a key instead of the string $ current_location_id . You can use $ current_location ['id'] directly:

  $ _ POST [$ current_location ['id']]  

Even in your query:

 for  ($ y_count = 1; $ y_count & lt; = $ zone_height; $ y_count ++) {for ($ X_count = 1; $ x_count & lt; = $ zone_width; $ X_count ++) {$ result = mysql_query ("SELECT * location from location_zone = '$ zone_id' and x_location = '$ x_count' and y_location = '$ y_count' "); $ Current_location = mysql_fetch_array ($ result); $ Result = mysql_query ("UPDATE Places SET Population_Company = '". $ _ POST [$ current_location [' id ']]. "' Id id = '" $. $ Current_location [' id ']. "'" "); }}  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -