I'm creating a table (a list of job vacancy), which one of the column in every row has it's own link(another php file). When user click on "job name", it'll be directed to it's "job1.php"(for example job number 1). There are 3 pages: (1) job list page --> (2) job details + apply button --> (3) form to register
Question :I want the job name to be automatically filled in (3) "job name" input box when the user clicked on "apply" button in (2). How php knows which job is clicked during the (1)/(2) step? Please advise.
Thank you
***I used 【while($row = mysqli_fetch_array($result)】 to print the list of table from SQL.
(1) job list page PHP image of page (1)
<!DOCTYPE html>
</head>
<body>
<table border="1">
<tr>
<td>Job Serial Number</td>
<td>Job Name</td>
<td>Job Date</td>
</tr>
<?php
$conn=mysqli_connect('localhost','root','admin','function1');
$sql = "SELECT * FROM joblist";
$result = mysqli_query($conn, $sql);
while($row = mysqli_fetch_array($result)) {
echo "<tr>
<td>";
printf("%s",$row["jobno"]);
echo "</a></td>
<td><a href='job";
printf("%s",$row["jobno"]);
echo ".php'>";
printf("%s",$row["jobname"]);
echo "</td>
<td>";
printf("%s",$row["jobdate"]);
echo "</td>
</tr>";
}
?>
</table>
</body>
</html>
(2) job details + apply button PHP image of page (2)
<!DOCTYPE html>
<html>
<head>
<?php
$conn=mysqli_connect('localhost','root','admin','function1');
$sql = "SELECT * FROM joblist";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_array($result);
?>
</head>
<body>
<?php
echo '<h1>';
printf("%s",'Job Name:'.$row["jobname"]);
echo '</h1><br>';
echo 'Details: Clean the floor';
echo '<br>';
printf("%s",'Job Date:'.$row["jobdate"]);
?>
<br>
<form action="jobregister.php" method="post">
<button type="submit">Click me to apply</button>
</form>
</body>
</html>
(3) form to register PHP image of page (3)
<!DOCTYPE html>
<html>
<head>
<?php
$conn=mysqli_connect('localhost','root','admin','function1');
if ($conn->connect_error) die($conn->connect_error);
$sql = "SELECT * FROM joblist";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_array($result);
?>
</head>
<body>
<form method="post" action="registered.php">
Job Name:<input type="text" name="stdjob"><br>
Your Name:<input type="text" name="stdname"><br>
<button type="submit" name="submit">Submit Application</button>
</form>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire