|
|
|
ช่วยแก้ไข code update ให้ทีคือว่ามี update รูปแล้วก้อเอกสารพอ update อันใดอันหนึ่ง อีกอันจะกลายเป็นค่าว่างไปเลย |
|
|
|
|
|
|
|
<Code (PHP)
?
require('../connect.php');
$news_pic = $HTTP_POST_FILES['news_pic']['name'];
if (is_uploaded_file($HTTP_POST_FILES['news_pic']['tmp_name']))
{ copy($HTTP_POST_FILES['news_pic']['tmp_name'], "File_Images/$news_pic");
echo "Upload Filename: " . $news_pic ;
} else
{ echo "Upload not complete"; }
$news_pdf = $HTTP_POST_FILES['news_pdf']['name'];
if (is_uploaded_file($HTTP_POST_FILES['news_pdf']['tmp_name']))
{ copy($HTTP_POST_FILES['news_pdf']['tmp_name'], "File_Documents/$news_pdf");
echo "Upload Filename: " . $news_pdf ;
} else
{ echo "Upload not complete"; }
$news_id = $_GET[news_id];
$news_topic = $_POST[news_topic];
$news_mes = $_POST[news_mes];
$news_start = $_POST[exampleI];
$news_time = $_POST[news_time];
$strSQL = "UPDATE news SET ";
$strSQL .="news_topic = '$news_topic' ";
$strSQL .=",news_mes = '$news_mes' ";
$strSQL .=",news_pic = '$news_pic' ";
$strSQL .=",news_pdf = '$news_pdf' ";
$strSQL .=",news_start = '$news_start' ";
$strSQL .=",news_time = '$news_time' ";
$strSQL .="WHERE news_id = '$news_id' ";
$objQuery = mssql_query($strSQL);
echo $strSQL;
if($objQuery)
{
echo "Save Done";
}
else
{
echo "Error Save [".$strSQL."]";
}
mssql_close($objConnect);
Tag : PHP, MySQL, Ms SQL Server 2005, Ms SQL Server 2008, HTML/CSS, JavaScript
|
|
|
|
|
|
Date :
2011-05-06 11:32:55 |
By :
silfareal |
View :
834 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตัวอย่างการแก้ไขไฟล์ครับ
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<?
//*** Update Record ***//
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "UPDATE files ";
$strSQL .=" SET NAME = '".$_POST["txtName"]."' WHERE FilesID = '".$_GET["FilesID"]."' ";
$objQuery = mysql_query($strSQL);
if($_FILES["filUpload"]["name"] != "")
{
if(copy($_FILES["filUpload"]["tmp_name"],"myfile/".$_FILES["filUpload"]["name"]))
{
//*** Delete Old File ***//
@unlink("myfile/".$_POST["hdnOldFile"]);
//*** Update New File ***//
$strSQL = "UPDATE files ";
$strSQL .=" SET FilesName = '".$_FILES["filUpload"]["name"]."' WHERE FilesID = '".$_GET["FilesID"]."' ";
$objQuery = mysql_query($strSQL);
echo "Copy/Upload Complete<br>";
}
}
?>
<a href="PageUploadToMySQL3.php">View files</a>
</body>
</html>
Go to : PHP สร้างฟอร์มสำหรับ Upload รูปภาพลงในฐานข้อมูล MySQL พร้อมกับแบบ Form สำหรับการแก้ไขรูปภาพ
|
|
|
|
|
Date :
2011-05-06 11:45:37 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ครับ ขอบคุณมากครับ
|
|
|
|
|
Date :
2011-05-06 11:46:43 |
By :
silfareal |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|