I need help again with figuring out how to pass data from one page to another while using a hyperlink. I managed to get all the regular input field filled-in with the $_GET global through url but can’t seem to be able to stick it inside two of my select tags:
here is the receiving form:
<form enctype="multipart/form-data" method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name"MAX_FILE_SIZE" value="32768" />
<label for="employeeactive" class="label" >Employee Active:</label>
<input name="employeeactive" type="checkbox" required class="input" id="employeeactive" <?php if (isset($_GET['employeeactive']) && $_GET['employeeactive']== 1) echo "checked";?>/>
<label for"jobtitleid" class="label">Job title</label>
<select type="text" required name="jobtitleid" class="input" id="jobtitleid"/>
<option value="select"></option>
<?php
$jobtitle = "SELECT * FROM jobtitle";
$jobresult= mysqli_query($dbc, $jobtitle);
while($option = mysqli_fetch_array($jobresult)){
$selectedjobtitleid = (isset($_SESSION['jobtitleid']) && $_SESSION['jobtitleid']);
echo '<option class"input" value="' . $option['jobtitleid'] . '"' . $selectedjobtitleid .'>' . $option['jobtitle'] . '</option>'."\r";
}
?>
</select>
<label for"employerid" class="label">Employer</label>
<select type="text" required name="employerid" class="input" id="employerid"/>
<option class="option" value="<?php echo $_GET['employerid']; ?>" ></option>
<?php
if(isset($_GET['employerid'])){
$employerid = $_GET['employerid'];
}
$employerslq = "SELECT employerid, employer FROM employer WHERE employerid= '$employerid'";
$resemp = mysqli_query($dbc, $employerslq);
while ($resemp2 = mysqli_fetch_array($resemp)){
echo'<option value="' .$resemp2['employerid'].'" >' . $resemp2['employer'] . '</option>'."\r";
}else{
$employer = "SELECT employerid,employer FROM employer";
$empresult= mysqli_query($dbc, $employer);
while($optionemp = mysqli_fetch_array($empresult)){
$selectedemployerid = (isset($_SESSION['employerid']) && $_SESSION['employerid']);
echo '<option class="option" value="' . $optionemp['employerid'] . '"' . $selectedemployerid .'>' . $optionemp['employer'] . '</option>'."\r";
}
echo $employerid;
?>
</select>
<label for="employeeid" class="label" >Employee ID:</label>
<input name="employeeid" type="text" required class="input" id="employeeid" value="<?php echo $_GET['employeeid']; ?>"/>
<label for="firstname" class="label" >First Name:</label>
<input name="firstname" type="text" required class="input" id="firstname" value="<?php echo $_GET['firstname']; ?>"/>
<label for="lastname" class="label" >Last Name:</label>
<input name="lastname" type="text" required class="input" id="lastname" value="<?php echo $_GET['lastname']; ?>" />
<label for="address" class="label" >Address:</label>
<input type="text" class="input" id="address" name="address" value="<?php echo $_GET['address']; ?>" />
<label for="city" class="label" >City:</label>
<input type="text" class="input" id="city" name="city" value="<?php echo $_GET['city']; ?>" />
<label for="province" class="label" >Province:</label>
<input type="text" class="input" id="province" name="province" value="<?php echo $_GET['province']; ?>"/>
<label for="country" class="label" >Country:</label>
<input type="text" class="input" id="country" name="country" value="<?php echo $_GET['country']; ?>" />
<label for="postalcode" class="label" >Postal Code:</label>
<input type="text" class="input" id="postalcode" name="postalcode" value="<?php echo $_GET['postalcode']; ?>"/>
<label for="phone" class="label" >Phone:</label>
<input type="tel" class="input" id="phone" name="phone" value="<?php echo $_GET['phone']; ?>"/>
<label for="email" class="label" >Email:</label>
<input type="email" class="input" id="email" name="email" value="<?php echo $_GET['email']; ?>"/><br /><br />
<label class="label" id="employeecommentlabel" for="employeecomment">Employee Comment:</label><br />
<textarea name="employeecomment" class="textarea" type="text"></textarea><br />
<label class="label" id="employeepiclabel"for="employeepic">Employee Picture:</label>
<input class="input"type="file" name="employeepic" id="employeepic" />
<input class="input" id="empsubmit" type="submit" name="submit" value="Save"/>
</form>
and here is the sending code:
echo'<table class="tblviewemp" >';
echo '<thead>';
echo '<tr class="tblviewemp">';
echo'<th class="dataH" id="emppicthumb">Employee Pic </th>';
echo'<th class="dataH"> First Name</th>';
echo'<th class="dataH">Last Name </th>';
echo'<th class="dataH"> ID</th>';
echo'<th class="dataH"> Update</th>';
echo '</thead>';
// Display the employee data and link to update
while ($row = mysqli_fetch_array($result)) {
echo '<tr>';
//echo '<td class="thumb"><img src="' . EMP_UPLOADPATH . $row['employeepic'] . '" alt="Employee image" /></td>';
echo '<td class="data">' . $row['employeeid'] . '</td>';
echo '<td class="data">' . $row['firstname'] . '</td>';
echo '<td class="data">' . $row['lastname'] . '</td>';
echo '<td><a href="update_employee.php?' .'&employeeactive=' . $row['employeeactive'] .
'&employeeid=' . $row['employeeid'] .
'&employerid=' . $row['jobtitleid'] .
'&jobtitleid=' . $row['firstname'] .
'&firstname=' . $row['firstname'] .
'&lastname=' . $row['lastname'] .
'&address=' . $row['address'] .
'&city=' . $row['city'] .
'&province=' . $row['province'] .
'&country=' . $row['country'] .
'&postalcode=' . $row['postalcode'] .
'&phone=' . $row['phone'] .
'&email=' . $row['email'] .'">update</a></td>';
}
echo '</tr>';
echo'</table>';