| PID | CID | tel_numbers |
| 1 | 1 | 1231231123 | PID = auto increment (phone_id current table)
| 2 | 1 | 124312412 | CID = id of contacts (contact_id from contact table)
| 3 | 2 | 43543545 | tel_numbers
| 4 | 2 | 12123123 |
| 5 | 3 | 23423423 |
| 6 | 4 | 22342342 |
I am new in php need help to fetch all data by CID in respective input fields to make editable but below code only display every first record of CID;
//PHP GET by id
require_once('config.php');
$conn = connect();
$id = $_GET['id'];
$sql = "SELECT * FROM addr_phone WHERE CID = $id ";
$query = $conn->query($sql);
$result = $query->fetch_array();
$conn->close();
//And display fields
DISPLAY FIELDS
<div class=" input_fields_wrap row">
<span class="input-group-btn " id="sizing-addon1">
<input type="tel" maxlength="10" name="ephone[]" class="form-control phone" value="<?=$result['tel_numbers']?>" placeholder="Phone Number">
<input type="tel" maxlength="10" name="ephone[]" class="form-control phone" value="<?=$result['tel_numbers']?>" placeholder="Phone Number">
</span>
</div>
e.g if i select CID = "2" so it should display both tel_numbers first in 1st input field and second in 2nd input field.
Above code display first record in both input fields and second one not showing but i want to display all tel_numbers by CID in each input field one by one.
i used while loop but required both input at the same time to display. if i have only one tel_number and want to add another tel_number number so i need both input fields.
Actually this form is designed for edit/ phone number if someone already added 1st phone number and required to update/add another phone number . e,g if cid= "3" which has only 1st tel_number to display in input through while loop and i want to add cid= "3" second tel_number so there must be input required .
Thanks