In my form, I generate input fields with php in my add.php page:
<?php
$inc = 0;
$inputNames = array(
array("Name", 'r_name', 'rd-id-'),
array("Surname", 'r_surname', 'rd-id-'),
array("Phone", 'r_phone', 'rd-id-'),
array("Email", 'r_email', 'rd-id-'),
);
foreach ($inputNames as $inp) { ?>
<div class="col-md-6">
<div class="form-group">
<label><?php echo $inp[0]; ?></label>
<input id="<?php echo $inp[2] . $inc; ?>" type="text"
class="form-control border-input"
placeholder="<?php echo $inp[0]; ?>"
name="<?php echo $inp[1]; ?>"
value="">
</div>
</div>
<?php
$inc++;
}
?>
The question is, how can I echo values from database in this loop? For example, in my edit.php page, I have variables like this:
$name = $_POST['r_name'];
$surname = $_POST['r_surname'];
$phone = $_POST['r_phone'];
$email= $_POST['r_email'];
I have tried to modifie the $inputNames array, to add a third value like:
<?php echo inp[3]; ?>
but it didn't work.