I just want to ask if it is possible to create variables on a php file so that the new input fields that I will create using a Content Management System (CMS) will have it's data stored on that new variables so I can query all those data to the database. (I'm sorry I'm so bad at explaining).
For example, I have this 4 Input Fields which has its own variable to house their data; Lastname, Firstname, Middlename, and Phone Number
sample code:
<div class="box-divide">
<b>Lastname:</b>
<input type="text" name="last_name" id="ln" placeholder="Lastname" required>
</div>
<div class="box-divide">
<b>Firstname:</b>
<input type="text" name="first_name" id="fn" placeholder="Firstname" required>
</div>
<div class="box-divide">
<b>Middlename:</b>
<input type="text" name="middle_name" id="mn" placeholder="Middlename" required>
</div>
<div class="box-divide">
<b>Phone Number:</b>
<input type="tel" name="phoneNum" id="pn" value="" placeholder="+639123456789" maxlength="13" required>
</div>
and I add this php codes to print new input fields:
<?php
//Select All Items for new Field
$sqlFD = "SELECT * FROM app_fields_lists";
$resFD = mysqli_query($conn, $sqlFD);
if (mysqli_num_rows($resFD) > 0) {
while ($rowFD = mysqli_fetch_assoc($resFD)) {
$idFD = $rowFD['id'];
$field_name = $rowFD['field_name'];
$uCapAFA = strtolower($field_name); // TO LOWER CASE STRING
$uCapAFA = str_replace(" ", "_", $uCapAFA); // REPLACE SPACE TO UNDERSCORE "_" TO CREATE/ADD TABLE COLUMN
?>
<div class="box-divide">
<b><?php echo $field_name ?>:</b>
<input type="text" name="<?php echo $uCapAFA ?>" id="<?php echo $uCapAFA ?>" value="" placeholder="<?php echo $uCapAFA ?>" required>
</div>
<?php
}
}
?>
All are successful on the CMS part. I'm sorry I can't show you guys the codes on the CMS part. I was able to alter the table I want to add the new input fields to. And can also delete/drop columns when I delete a column.
All was going fine but now I'm stuck. I can't think of a doable solution on this problem. Was thinking of using loop too but I don't know what follows after making the first part.
This all seems like a real headache, but I don't have anyone to ask about this, that's why I'm trying to push my luck in here. Thanks in advance!