I am creating a web app that should insert jobs into the database for logged in users, after you click a job on the listview,a page is displayed showing the jobs,city,details then you have two buttons,apply and favorites,apply works just fine,favorites insert the selected job into a table and write it to another page "favorite" in a listview using php,It does write it but all the job selected by a specific user as favorite appear on a single listview block and i also want to create a link to the job file that specify all the details about that job.
Here are my Jquery and my PHP codes
<div data-role="page" id="page6" data-add-back-btn="true">
<div data-role="header">
<h1>Favorites</h1>
</div>
<div data-role="content">
<?php
if(isset($_POST['submit'])){
move_uploaded_file($_FILES['file']['tmp_name'],"picture-upload/".$_FILES['file']['name']);
$con=mysqli_connect("localhost","root","","recruitment");
$q=mysqli_query($con,"UPDATE users SET image='".$_FILES['file']['name']."'where username='".$_SESSION['username']."'");
}
?>
<form action="index.php" method="post" enctype="multipart/form-data" data-ajax="false">
<h5><span>
<div id="box1">
<input name="file" id="file" class="hidden" type="file" ><br>
<button type="submit" class="btn btn-primary" name="submit" data-role="none">Upload picture</button>
<?php
$con=mysqli_connect("localhost","root","","recruitment");
$q=mysqli_query($con,"SELECT * from users where username='".mysql_real_escape_string($_SESSION['username'])."'");
while($row=mysqli_fetch_assoc($q)){
/*echo $row['username'].'<br>';*/
if($row['image']==""){
echo'<img id="profile-image" width="50" height="50" src="picture-upload/defaultimage.png" alt="Default profile picture">';
}
else{
echo'<img id="profile-image" width="50" height="50" src="picture-upload/'.$row['image'].'" alt="Profile picture">';
}
}
?>
</div>
</br></span>
<?php echo 'Welcome '.$_SESSION['username'];
echo "<br><a href='logout.php' data-ajax='false'>Logout</a>"; ?> ...</h5>
<?php
//login.php
include_once 'Dbconnect.php';
$JobUser=$_SESSION['username'];
// Select the database.
mysql_select_db($db_database)
or die("Unable to select database: " . mysql_error());
$sql="select * from favorites where username='$JobUser'";
$record=mysql_query($sql);
?>
<div id="output"></div>
<ul data-role="listview" data-inset="true" data-filter="true" id="list_jobs">
<li data-role="list-divider">
<?php
while($users=mysql_fetch_assoc($record)){
echo"<tr>";
echo"<td>".$users['jobid']."</td>";
echo"<td>".$users['jobcity']."</td>";
echo"<td>".$users['jobtitle']."</td>";
echo"</tr>";
}
exit;
?>
</li>
</ul>
</div>
<div data-role="footer">
<h4>©2016 • Genesis M&C Holdings Pty</h4>
</div>
</div>