I'm trying to download uploaded file in my database before refreshing the web page. I mean, when I upload file with form, I want to download it without refreshing. In my result now, when I click to download it, I download the last file before inserting the new one where I did refresh after inserting it.
Note: I can download it after refreshing the page.
The form use jquery function to submit the form contains the file to upload.
Maybe the problem is in downloadtd.php?td_id=".$tdid
where the value of $tdid
is not the correct one.
I know my problem is a little bit complicated to understand. I hope that you can help me. So,please let me know if you didn't understand my problem exactly.
<?php
$query="SELECT * from td where d_id=$id";
$res=mysqli_query($conn,$query);
if(mysqli_num_rows($res)) {
while($r=mysqli_fetch_assoc($res)) {
$tdid=$r['td_id'];
?><div class="new">
<a id="io<?php echo $id ?>" href="<?php echo"downloadtd.php?td_id=".$tdid ?>">
<span id="tdt<?php echo $tdid ?>">
<img src="images/des3.png" width="15px" height="15px">  
<span style="font-size: 13px"></span>
</span>
</a>
</div><?php
}
} else {
$query="SELECT * from td where d_id=$id order by td_id desc";
$res=mysqli_query($conn,$query);
$r=mysqli_fetch_assoc($res);
$tdid=mysqli_query($conn,$sq);
?><a id="io<?php echo $id ?>" href="<?php echo "downloadtd.php?td_id=".$tdid?>" style="text-decoration: none;" ></a><?php
}
?>