如何在php和mysql中保存,显示和打开excel附件 [英] How to save,display and open excel attachment in php and mysql

查看:66
本文介绍了如何在php和mysql中保存,显示和打开excel附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我有这个问题,目前能够在mysql数据库中保存附件名称。但是,保存后它不会在表单中显示附件名称,因此无法打开附件。下面是编码。请在单击提交按钮后告知如何显示附件名称并打开附件。真的很感谢你的帮助和非常感谢。



Hi everyone, I have this issue, currently am able to save the attachment name in mysql database. However, after saving it doesn't display the attachment name in the form and so unable to open the attachment. Below is the coding. Please advise how to display the attachment name and open the attachment after clicking submit button. Really appreciate your help and thanks a lot.

<html>
<body> 
<form name="progress" id="progress" method="post" action=""> <div id="tabs-1"> 
session_start();
$con = mysql_connect("localhost","user","");

if (!$con){
die("Can not connect: " . mysql_error());

}
mysql_select_db("pq",$con);

$Picid = $_GET['Picid'];
$nwQty = "SELECT * FROM progress WHERE Picid = '$Picid'";
// check if the progress is already
$solution = mysql_query($nwQty);

if(isset($_POST['submit'])){
if (mysql_num_rows($solution) == 0){
// put the progress in table
$sql = "INSERT INTO progress(Quanprogress1,Qualprogress1,Attachment1,Picid) VALUES ('" . $_POST["Quanprogress1"] . "','" . $_POST["Qualprogress1"] . "','" . $_POST["Attachment1"] . "','" . $Picid . "')";
$result = mysql_query($sql);

} else {
// update progress in table
$sql =("UPDATE progress SET Quanprogress1='" . $_POST["Quanprogress1"] . "', Qualprogress1='" . $_POST["Qualprogress1"] . "', Attachment1='" . $_POST["Attachment1"] . "' WHERE Picid='" . $Picid . "'");
$result = mysql_query($sql);
echo('Record Updated');

}
$result = mysql_query("SELECT * FROM progress WHERE Picid='$Picid' ");
$row= mysql_fetch_array($result);

}
?> <p>1.Target</p>
<table>
<tr>
<td><font size="2">a.i.Quantitative Progress:</font></td>
<td><input type="text" name="Quanprogress1" id="Quanprogress1" class="txtField" value="<?php echo $row['Quanprogress1']; ??>"></td>
<td><font size="2">a.ii.Qualitative Progress: </font></td>
<td><input type="text" name="Qualprogress1" id="Qualprogress1" class="txtField" value="<?php echo $row['Qualprogress1']; ??>"></td>
</tr>
</table>
<p><enctype>c.i.Preformatted Forms: <input type="file" name="Attachment1" id="Attachment1" MAXLENGTH=50 ALLOW="text/*" value="<?php echo $row['Attachment1']; ??>"></enctype></p>
<input type="hidden" name="Picid" id="Picid" value="<?php echo $row['Picid']; ??>" >
<input type="hidden" name="Progressid" id="Progressid" value="<?php echo $row['Progressid']; ??>">
<table><tbody><tr><td colspan="2"><input type="submit" name="submit" id="submit" value="Save" class="btnSubmit"></td></tr></tbody></table>
</div>
</form>
</body>
</html>

推荐答案

con = mysql_connect(localhost,user,);

if(!
con = mysql_connect("localhost","user",""); if (!


con){
die(无法连接:。mysql_error());

}
mysql_select_db(pq,
con){ die("Can not connect: " . mysql_error()); } mysql_select_db("pq",


con);


这篇关于如何在php和mysql中保存,显示和打开excel附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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