在MySQL中与其他记录(varchar)一起存储和打开pdf文件 [英] storing and opening pdf files with other records(varchar) in mysql

查看:72
本文介绍了在MySQL中与其他记录(varchar)一起存储和打开pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..
我想使用php ..从MySQL获取mysql的记录和pdf文件,并带有删除记录的选项,并且从表显示时,除pdf文件外,所有其他记录都将显示.对于pdf文件,我希望链接为显示pdf"或阅读更多".如果单击此链接,则该特定记录的pdf文件应在新窗口中打开.为此,我尝试使用

Hi..
I want to fetch records and pdf files from mysql using php.. with a option delete records and while displaying from table all other records will be displayed except pdf files. for pdf file I want a link as "show pdf" or "read more". if clicked on this link, pdf file of that particular record should open up in new window. For this i tried using

<form name="form2" action="test_mix.php" method="POST">

<table id="displaytable" width="400" border="0" align="center" cellpadding="0" cellspacing="1" style="vertical-align:middle;">
<tr>
<td><table width="421" height="279" border="0" cellpadding="3" cellspacing="1">
<tr>
<td width="29" rowspan="5" style="vertical-align:middle;">
<?php



echo "<input type=checkbox name=del[] id=del value=$rows[id]>";
?>


</td>
</tr>

<tr>
<td width="83">Date</td>
<td width="6">:</td>
<td width="276"><?php echo $rows['date']; ?></td>
</tr>

<tr>
<td valign="top">Title</td>
<td valign="top">:</td>
<td><?php echo $rows['title']; ?></td>
</tr>
<tr>

<tr>
<td valign="top">News</td>
<td valign="top">:</td>
<td><?php echo $rows['news']; ?></td>
</tr>
<tr>
<td height="55" valign="top" style="vertical-align:middle;"></td>
<td valign="top"><?php echo "<input type=checkbox id=pdf value=$rows[id] onclick=Button1() name=pdf[];/>" ?>
<!--<input type="submit" name=pdf[] id=pdf value=$rows[id] formtarget="_blank" src="Untitled-7.php" />
-->
<!--<a href="javascript:void(0);"<?php /*?> <?php name=pdf[]; id=pdf; value=$row[id];?><?php */?> onclick="javascipt:window.open('Untitled-7.php');" class="popup">Clic to open.</a>-->

<!--<a href="Untitled-7.php" target="_blank" >Read More</a>--></td>
<td height="200" width="6" style="overflow:auto;">:</td>

<?php /*?><?php echo $rows['file']; ?><?php */?>
</tr>


</table></td>
</tr>
</table>

<?php

}

mysql_close(); //close database

?>
<!--<input type="submit" name="justdel" value="Delete !!" id="justdel" style="float:right;">-->
<INPUT type="button" value="Delete !!" name=justdel  id="justdel" onclick="return OnButton2();"  style="float:right;">
</form>




这是test_mix.php




and this is test_mix.php

<?php
 //delete.php
include('update_config.inc');

if($_POST['del']=""){

//if(isset($_POST['justdel'])){

//if(($_POST['del']) = "";){

$id = $_POST['del'];
$count = count($id); //counting how many rows (from checkbox) to delete
for ($i=0; $i<$count; $i++)
{
$sql = mysql_query("delete from $tbl_name where id=$id[$i]") or die(mysql_error());
}
if ($sql)
{
header("location:adminupdates.php");
}
}
else if(($_POST['pdf']="")){

$id = $_POST['pdf'];
$count = count($id); //counting how many rows (from checkbox) to delete
//if($_POST['pdf'])

$gotten = @mysql_query("select file from $tbl_name where id=$count limit 1");
$row = @mysql_fetch_assoc($gotten);
$bytes = $row['file'] or die(mysql_error());
//header("Content-Description: PHP Generated Data");
header("Content-transfer-encoding: binary");
header("Content-type: application/pdf");
//header('Content-disposition: attachment; filename="thing.pdf"');
//print $bytes;

 print $bytes;

        }
    else{echo "in three";}
//}
?>



谁能帮助我..



can any one please help me in this..

推荐答案

行[id] > ; ?> < /td > < /tr > < tr > < td =" 83" < > < td =" 6" < > < td =" 276" <? 回声
rows[id]>"; ?> </td> </tr> <tr> <td width="83">Date</td> <td width="6">:</td> <td width="276"><?php echo


行['date']; ? < > < /tr > < tr > < td =" top" < > < td =" top" < > < td > <? php
rows['date']; ?></td> </tr> <tr> <td valign="top">Title</td> <td valign="top">:</td> <td><?php echo


rows ['title']; ? > < /td > < /tr > < tr > < tr > < td =" top" < > < td =" top" < > < td > <? php
rows['title']; ?></td> </tr> <tr> <tr> <td valign="top">News</td> <td valign="top">:</td> <td><?php echo


这篇关于在MySQL中与其他记录(varchar)一起存储和打开pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆