I have a POST
variable that is used to get data from my MySQL, but it's not working, there's something wrong with my POST data.
I have tried to escape a variable put in the $_POST
variable using {$_POST[$var]}
,but the main problem is that I cannot put the {$_POST[$var]}
in the SQL statement. Here is my code:
for($i = 0; $i < mysqli_num_rows($result); $i++){
$sqlx = mysqli_query($conn, "UPDATE manager_details
SET article = '{$_POST[input_article$i]}' WHERE field_id ='1'"));
}
In this case, the SQL
statement isn't running.
And here is my my html form :
$result = mysqli_query($conn, "SELECT field_name FROM
manager_master");
while($row = mysqli_fetch_array($result)){
$fieldname[] = $row["field_name"];
}
echo $fieldname[1];
for($i = 0; $i < mysqli_num_rows($result); $i++){
echo "<tr><td>$fieldname[$i]</td><td><form action='update.php'
method='post'><textarea name='input_$fieldname[$i]'></textarea></td>
<tr>";
}
//</form> outside the loop