Reputation: 37
I have a POST called
name='update_name".$id."'
This ID comes from an Foreach.
And i dont know how to call this POST because there is an variable inside.
I'm using MVC, i created the function inside the model, and i'm calling the function inside view:
But i dont know how to call the variable.
I want my script to read the name like this:
$variable = $_POST['update_name1'];
How can i do that?
Upvotes: 0
Views: 128
Reputation: 2437
<input name="update_name<?php echo $id; ?>" value="">
And you can read it as:
$variable = $_POST['update_name'.$i];
Upvotes: 0
Reputation: 1100
Same way as setting the tame of your input
$variable = $_POST['update_name'.$i];
Bud i recomend you to use name attribute as array
HTML
<input type="text" name="update_name[]" />
<input type="text" name="update_name[]" />
PHP
<?
foreach ($_POST[update_name] as $item){
// $item `s are now values from input
}
?>
Upvotes: 3