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"> <?php
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><b>1.Target</b></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="multipart/form-data">c.i.Preformatted Forms: <input type="file" name="Attachment1" id="Attachment1" MAXLENGTH=50 ALLOW="text/*" value="<?php echo $row['Attachment1']; ?>"></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']; ?>">
<td colspan="2"><input type="submit" name="submit" id="submit" value="Save" class="btnSubmit"></td>
</div>
</form>
</body>
</html>