I have a subform called "Contacts" embedded on my "Tickets" page. I want to create an edit button to jump to my contacts_edit.php page and use the 'ContactEntryNumber' (the unique key from my Contacts table) for the displayed contact record as the updateID. I have played with this and read articles until my head spins but I can't get it to work. I'm a NOVICE php coder so it's probably just a fundamental misunderstanding of how the code should work. Below is the code including the button I created. It will currently take me to the correct edit page but instead of grabbing the updateID numeric value, it literally just inserts the words updateID=$contactsEntryNumber. I know I need to declare that value somewhere but all the methods I have tried don't work.
Here is my sql code:
$contactSql = "SELECT * FROM `Tickets` as t
JOIN Contacts as co ON t.CustomerID=co.ContactId
WHERE t.TicketNumber ='$ticketNumber'
"
;
$contactResult = $conn->query($contactSql);
if ($contactResult->num_rows > 0) {
$contactRow = $contactResult->fetch_all(MYSQLI_ASSOC);
}
Here is the code for this section of the page:
<div class="row mb-2">
<label for="Customer_Contacts" class="col-sm-8 col-form-label">Customer Contact Information</label>
<div class="col-12">
<table id="Customer_Contacts" class="table table-bordered" style="color:#F46813 ;border-color:#F46813;border:1px">
<thead class="thead-dark">
<th >Selected</th>
<th>Name</th>
<th>Phone Main</th>
<th>Phone Mobile</th>
<th>Phone Home</th>
<th>Email</th>
</thead>
<?php foreach ($contactRow as $key=>$value){?>
<tr>
<td><?php if($value['Select'] =='-1'){?>
<i class="fa fa-check-circle-o"></i>
<?php }?></td>
<td><?=(($value['ContactLast'] !='') ? $value['ContactFirst'].' '.$value['ContactLast'] :'')?></td>
<td><?=(($value['PhoneMain'] !='') ? $value['PhoneMain'] :'')?></td>
<td><?=(($value['PhoneMobile'] !='') ? $value['PhoneMobile'] :'')?></td>
<td><?=(($value['PhoneHome'] !='') ? $value['PhoneHome'] :'')?></td>
<td><?=(($value['Email'] !='') ? $value['Email'] :'')?></td>
<td><button class=\"btn btn-primary btn-sm\"><a href=\"contacts_edit.php?updateid=$contactsEntryNumber\" class=\"text-light\">EDIT</a></button></td>
</tr>
<?php }?>
</table>
</div>
</div>