我有以下代码供下载选项:
<a href='http://xyz.net/video/<?php echo $row['video_name']?>'
title='click to download this video'>
<img src="resources/images/icons/download.png"/>
哪种方法正常。
现在,我想将我的下载表更新为
UPDATE video_uploaded SET downloaded = 1 WHERE video_id = '211'
//here video_id is dynamic and it's not a problem
如何在此代码段中添加重定向到其他网页选项:
<a href='http://xyz.net/video/<?php echo $row['video_name']?>'
title='click to download this video'>
<img src="resources/images/icons/download.png"/>
这样当用户首先点击“下载”按钮时,它会下载该文件,然后更新该表。
答案 0 :(得分:0)
我会做这样的事情:
<a id='mylink' href='http://xyz.net/video/<?php echo $row['video_name']?>'
title='click to download this video'>
<img src="resources/images/icons/download.png"/>
然后使用jQuery调用脚本来更新表:
$('#mylink').click(function(){
$.post('script.php');
});
编辑:
由于关于检查成功下载的评论,我试试这个:
$('#mylink').click(function(){
$.post('downloadScript.php', function(data){
if(data){
$.post('updateScript.php');
}
else{
// do whatever on failed download
}
};
});