Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > อัพเดทแล้วค่าของรูปภาพเป็นค่าว่าง อยากให้เมื่ือกดอัพเดทเป็นรูปเดิม ช่วยแนะนำมือใหม่ให้หน่อยครับ



 

อัพเดทแล้วค่าของรูปภาพเป็นค่าว่าง อยากให้เมื่ือกดอัพเดทเป็นรูปเดิม ช่วยแนะนำมือใหม่ให้หน่อยครับ

 



Topic : 125580



โพสกระทู้ ( 58 )
บทความ ( 0 )



สถานะออฟไลน์




อยากให้เมื่อกด update แล้วไฟล์เก่าที่อัพไป ยังอยู่เหมือนเดิมครับ
เช่น เมื่อผมเพิ่มข้อมูลเข้าไปแล้ว แล้วพอมาแก้ไข
ผมแก้ไข แค่ textbox ยี่ห้อ เมื่อกดอัพเดท แล้วไฟล์รูปภาพจะหายถ้าเราไม่เลือกใหม่ครับ
อยากให้ไฟล์เดิมยังอยู่แม้จะไม่เลือกรุปใหม่

ไฟล์ editmain.php
Code (PHP)
<?php require_once('../Connections/ConnectSW.php'); ?>
<?php include("dw-upload.inc.php"); ?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "admin";
$MM_donotCheckaccess = "false";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && false) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "indexsrisawat.dwt.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
 

if((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
  $updateSQL = sprintf("UPDATE datacar SET car_id=%s, pic_car=%s, data_brand=%s, data_gene=%s, data_year=%s, data_pricesell=%s, data_cate=%s WHERE code_car=%s",
                       GetSQLValueString($_POST['car_id'], "int"),
                       GetSQLValueString(dwUpload($_FILES['pic_car']), "text"),
                       GetSQLValueString($_POST['data_brand'], "text"),
                       GetSQLValueString($_POST['data_gene'], "text"),
                       GetSQLValueString($_POST['data_year'], "text"),
                       GetSQLValueString($_POST['data_pricesell'], "text"),
                       GetSQLValueString($_POST['data_cate'], "text"),
                       GetSQLValueString($_POST['code_car'], "int"));

  mysql_select_db($database_ConnectSW, $ConnectSW);
  $Result1 = mysql_query($updateSQL, $ConnectSW) or die(mysql_error());
  



  $updateGoTo = "uploadmain.dwt.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
 

$colname_Recordset1 = "-1";
if (isset($_GET['codecar'])) {
  $colname_Recordset1 = $_GET['codecar'];
}
mysql_select_db($database_ConnectSW, $ConnectSW);
$query_Recordset1 = sprintf("SELECT * FROM datacar WHERE code_car = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $ConnectSW) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);$colname_Recordset1 = "-1";

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
<style type="text/css">
@import url("../buttons1.css");

body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	color: #FFF;
}
.dddd {
	color: #FFF;
	font-weight: bold;
	font-size: 24px;
}
.sss {
	color: #000;
}
.over {
	background-color: #69F;
}
</style>
<STYLE type=text/css>
.link_12_dark_blue:link {
font-family: MS Sans Serif, Tahoma, sans-serif;
font-size: 15px;
text-decoration: none;
color:#0066CC;
}
.link_12_dark_blue:visited {
font-family: MS Sans Serif, Tahoma, sans-serif;
font-size: 15px;
text-decoration: none;
color:#0066CC;
}
.link_12_dark_blue:active {
font-family: MS Sans Serif, Tahoma, sans-serif;
font-size: 15px;
text-decoration: none;
color:#0066CC;
}
.link_12_dark_blue:hover {
font-family: MS Sans Serif, Tahoma, sans-serif;
font-size: 15px;
text-decoration: none;
color:#FF0000;
}
</STYLE>
</head>

<body  background="../pmj/workshop/20-2/bg.jpg">
<table width="1100" border="1" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <th scope="col"><img src="../topmain4.jpg" width="1100" height="200" /></th>
  </tr>
  <tr>
    <th scope="row" class="sss" align="right" bgcolor="#6699FF" >ยินดีต้อนรับ คุณ:<?php echo $_SESSION['MM_name_ac']; ?>[สถานะ : <?php echo $_SESSION['MM_UserType']; ?>] 
      <input  name="btnlogout" type="button"  class="button-tiny"  id="btnlogout" value="LOG OUT!" onclick='location.replace("logout.php")' /> 
  </tr>
  <tr>
    <th bgcolor="#333333" scope="row"><span class="dddd">แก้ไขข้อมูลการอัพโหลดรูปภาพ(Main)</span></th>
  </tr>
  <tr>
    <th align="center" class="sss" bgcolor="#CCE3E9" scope="row">
      <table width="1100" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <th align="left" scope="col"><a href="uploadmain.dwt.php" class="link_12_dark_blue" style="text-decoration: none;">&lt;&lt;&lt;BACK&gt;&gt;&gt;<br />
          </a>
            <form id="form1" name="form1" method="post" action="">
            </form>
            <form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="form2" id="form2">
              <table align="center" onmouseover="className=&quot;over&quot;" onmouseout="className=&quot;&quot;" frame="box" >
                <tr valign="baseline">
                  <td align="right" nowrap="nowrap" bgcolor="#CCE3E9">รหัสรถยนต์:</td>
                  <td><input type="text" name="car_id" value="<?php echo htmlentities($row_Recordset1['car_id'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
                </tr>
                <tr valign="baseline">
              
                  <td align="right" nowrap="nowrap" bgcolor="#CCE3E9">รูปภาพ:</td>
          

                  <td><input type="file" name="pic_car" value="<?php echo htmlentities($row_Recordset1['pic_car'], ENT_COMPAT, 'utf-8'); ?>" size="32" /><?php echo htmlentities($row_Recordset1['pic_car'], ENT_COMPAT, 'utf-8'); ?> </td>
                
			
                </tr>
                <tr valign="baseline">
                  <td align="right" nowrap="nowrap" bgcolor="#CCE3E9">ยี่ห้อ:</td>
                  <td><input type="text" name="data_brand" value="<?php echo htmlentities($row_Recordset1['data_brand'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
                </tr>
                <tr valign="baseline">
                  <td align="right" nowrap="nowrap" bgcolor="#CCE3E9">แบบ(รุ่น):</td>
                  <td><input type="text" name="data_gene" value="<?php echo htmlentities($row_Recordset1['data_gene'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
                </tr>
                <tr valign="baseline">
                  <td align="right" nowrap="nowrap" bgcolor="#CCE3E9">ปี:</td>
                  <td><input type="text" name="data_year" value="<?php echo htmlentities($row_Recordset1['data_year'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
                </tr>
                <tr valign="baseline">
                  <td align="right" nowrap="nowrap" bgcolor="#CCE3E9">ราคาขาย:</td>
                  <td><input type="text" name="data_pricesell" value="<?php echo htmlentities($row_Recordset1['data_pricesell'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
                </tr>
                <tr valign="baseline">
                  <td align="right" nowrap="nowrap" bgcolor="#CCE3E9">ประเภท:</td>
                  <td><select type="text" name="data_cate" value="<?php echo htmlentities($row_Recordset1['data_cate'], ENT_COMPAT, 'utf-8'); ?>" /><option value="<?php echo htmlentities($row_Recordset1['data_cate'], ENT_COMPAT, 'utf-8'); ?>" hidden="" selected="selected"><?php echo htmlentities($row_Recordset1['data_cate'], ENT_COMPAT, 'utf-8'); ?></option>
                  <option value="รถเก๋ง">รถเก๋ง</option>
                  <option value="รถกระบะ">รถกระบะ</option>
                  </select></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right">&nbsp;</td>
                  <td><input type="submit" class="button-group" value="Update record" style="width:100px;height:40px" /></td>
                </tr>
              </table>
              <input type="hidden" name="MM_update" value="form2" />
              <input type="hidden" name="code_car" value="<?php echo $row_Recordset1['code_car']; ?>" />
            </form>
            <p>&nbsp;</p>
<a href="reservmenu.dwt.php"> </a></th>
        </tr>
    </table></th>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>


-------------------------------------------------------------------------------------------------------------------------------------

เรียกใช้ไฟล์ dw-upload.inc.php
Code (PHP)
<?php
function dwUpload($file,$path="./img-products/"){
	if(@copy($file['tmp_name'],$path.$file['name'])){
		@chmod($path.$file,0777);
		return $file['name'];
	}else{
		return false;
	}
}

?>





Tag : PHP, MySQL







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2016-11-30 19:53:17 By : tomzone2 View : 1179 Reply : 4
 

 

No. 1



โพสกระทู้ ( 328 )
บทความ ( 0 )



สถานะออฟไลน์


ใช้ dreamwaver ใช่มั้ยย






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-11-30 21:16:28 By : Luz
 


 

No. 2



โพสกระทู้ ( 58 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 1 เขียนโดย : Luz เมื่อวันที่ 2016-11-30 21:16:28
รายละเอียดของการตอบ ::
ใช่ครับ ฮ่า ๆ พอจะช่วยได้มั้ยครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-11-30 22:01:57 By : tomzone2
 

 

No. 3



โพสกระทู้ ( 328 )
บทความ ( 0 )



สถานะออฟไลน์


Code (PHP)
if(!empty($_FILES['pic_car']['tmp_name])
{
$updateSQL = sprintf("UPDATE datacar SET car_id=%s, pic_car=%s, data_brand=%s, data_gene=%s, data_year=%s, data_pricesell=%s, data_cate=%s WHERE code_car=%s",
                       GetSQLValueString($_POST['car_id'], "int"),
                       GetSQLValueString(dwUpload($_FILES['pic_car']), "text"),
                       GetSQLValueString($_POST['data_brand'], "text"),
                       GetSQLValueString($_POST['data_gene'], "text"),
                       GetSQLValueString($_POST['data_year'], "text"),
                       GetSQLValueString($_POST['data_pricesell'], "text"),
                       GetSQLValueString($_POST['data_cate'], "text"),
                       GetSQLValueString($_POST['code_car'], "int"));

  mysql_select_db($database_ConnectSW, $ConnectSW);
  $Result1 = mysql_query($updateSQL, $ConnectSW) or die(mysql_error());
  
}else{
$updateSQL = sprintf("UPDATE datacar SET car_id=%s,data_brand=%s, data_gene=%s, data_year=%s, data_pricesell=%s, data_cate=%s WHERE code_car=%s",
                       GetSQLValueString($_POST['car_id'], "int"),
                       GetSQLValueString($_POST['data_brand'], "text"),
                       GetSQLValueString($_POST['data_gene'], "text"),
                       GetSQLValueString($_POST['data_year'], "text"),
                       GetSQLValueString($_POST['data_pricesell'], "text"),
                       GetSQLValueString($_POST['data_cate'], "text"),
                       GetSQLValueString($_POST['code_car'], "int"));

  mysql_select_db($database_ConnectSW, $ConnectSW);
  $Result1 = mysql_query($updateSQL, $ConnectSW) or die(mysql_error());
  
}

ตอบในโทรศัพท์ ไปทำโค้ดไห้มันสั้นเองนะ 55


ประวัติการแก้ไข
2016-11-30 23:31:38
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-11-30 23:26:46 By : Luz
 


 

No. 4



โพสกระทู้ ( 58 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 3 เขียนโดย : Luz เมื่อวันที่ 2016-11-30 23:26:46
รายละเอียดของการตอบ ::
ทำได้แล้วครับ ขอบคุณมากครับผม

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-12-01 13:06:43 By : tomzone2
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : อัพเดทแล้วค่าของรูปภาพเป็นค่าว่าง อยากให้เมื่ือกดอัพเดทเป็นรูปเดิม ช่วยแนะนำมือใหม่ให้หน่อยครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่