This is my page where I list all the jobs that have been posted by user in MySQL table. The thing that I want is to record how many times a specific job have been clicked or viewed and show it in the page where the job details are shown.
This is the page where I list the jobs: http://example.com/Job/
This is the page where job details have been shown: http://example.com/job/job.details.php?id=171
<?php
$result = mysqli_query($conn,"SELECT * FROM job ORDER BY `CreatedTime` DESC");
echo "<table border='0' cellpadding='0' cellspacing='0' class='table-fill'>
<tr>
<th width='300px' position='fixed' overflow='hidden'>Job Title</th>
<th width='100px'>Company Name</th>
<th width='100px'>Location</th>
<th width='80px'>Closing Date</th>
</tr>";
while($row = mysqli_fetch_array($result) ) {
echo "<tr>";
echo "<td><a href='job.details.php?id=".$row['jobid']."' class='positiontitle-link'>" . $row['positiontitle'] . "</td>";
echo "<td>" . $row['companyname'] . "</td>";
echo "<td>" . $row['location'] . "</td>";
echo "<td>" . $row['closingdate'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($conn);
?>
Thanks in advance.
This likely isn't the most efficient solution, but on the job.details.php page, you could include a query that runs a query something like:
UPDATE hit_tracking SET hits = hits + 1 WHERE jobid = ID
If this were to run each time the page was loaded, that would be one way to keep track of page views, although I'm sure there are better. Also, please remember to escape your ID field and that you'll have to add the row for the jobid at the creation of the job.