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 : 074779

Guest




อันนี้เป็นหน้าแก้ไขสินค้าค่ะ รายละเอียดทุกอย่างได้หมดค่ะ แต่พออัพรุปไม่ได้ค่ะ ไม่ก็อปปี้ไฟลืลงฐานข้อมูลค่ะ

หน้า prd_edit.php
<? include "chksession.php";?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>ผู้ดูแลระบบ</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="../style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #0000FF}
-->
</style>
</head>
<script>
function check_number() {
e_k=event.keyCode
//if (((e_k < 48) || (e_k > 57)) && e_k != 46 ) {
if (e_k != 13 && (e_k < 48) || (e_k > 57)) {
event.returnValue = false;
alert("กรอกเป็นตัวเลขเท่านั้น!");
}
}

function check(){
if(f1.product_name.value == ""){
alert("โปรดกรอกชื่อสินค้าค่ะ");
stop();
}
if(f1.product_detail.value == ""){
alert("โปรดกรอกรายละเอียดสินค้าค่ะ");
stop();
}
if(f1. product_price .value == ""){
alert("โปรดกรอกราคาสินค้าค่ะ");
stop();
}
else{
f1.submit();
}
}
</script>
<body leftmargin=0 topmargin=0 bgcolor="#BFA487">
<?
$id_prd_edit = $_GET [id_prd_edit] ;
$product_id = $_GET [product_id];
$product_name = $_GET [product_name];
$product_detail = $_GET [product_detail];
$product_price = $_GET [product_price];
$picture = $_GET [picture];
$status = $_GET [status];
$ref_type_id = $_GET [ref_type_id];

include("../connect.php");
$sql2 = "select * from product where product_id = '$id_prd_edit' " ;
$result2 = mysql_db_query ($db, $sql2) ;
$rs2 = mysql_fetch_array ($result2) ;
$product_id = $rs2 [product_id];
$product_name = $rs2 [product_name] ;
$product_detail= $rs2 [product_detail] ;
$product_price = $rs2 [product_price] ;
$stock = $rs2 [stock] ;
$picture= $rs2 [picture] ;
$status = $rs2 [status] ;
$ref_type_id= $rs2 [ref_type_id] ;

?>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="17" background="images/bg_left.gif"><img src="images/bg_left.gif" width="17" height="16"></td>
<td width="780" align=lift valign=top><table width="780" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align=lift valign=top>
<? include "menu.php"; ?>
</td>
</tr>
<tr>
<td height="20" align=lift valign=top><table width="780" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="200" height="20" align=lift valign=top>
<? include "menu_left.php"; ?>
</td>
<td width="580" align=lift valign=top><table width="550" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<table width="550" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bordercolor="#FAFAFA" ><p align="left" class="p"><strong>แก้ไขสินค้า </strong></p></td>
</tr>
<tr>
<td><form name="form1" method="post" action="prd_edit2.php" enctype="multipart/form-data" id="f1">
<table width="550" border="0" cellpadding="0" cellspacing="0" bordercolor="#eff2f3">
<tr>
<td bgcolor="#FFFFFF"><div align="right"></div></td>
<td><div align="right" class="menu"><font color="#FF0000">* โปรดกรอกข้อมูลที่มีเครื่องหมายให้ครบ</font></div></td>
</tr>
<tr>
<td width="185" bgcolor="#FFFFFF"><p align="right" class="p style1">ชื่อสินค้า
:</p></td>
<td width="357"> <p align="left" class="p"><input name="product_name" type="text" id="product_name" value="<? echo $product_name; ?> " size="50" maxlength="150" >
<font color="#FF0000">*</font> </p></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" ><p align="right" class="p style1">ประเภทสินค้า
:</p></td>
<td > <p align="left" class="p">
<select name="ref_type_id">
<?
$sql3 = "select * from type ";
$result3 = mysql_db_query($db,$sql3) ;
while ($rs3 = mysql_fetch_array($result3) ) {
$type_id = $rs3[type_id] ;
$type_name = $rs3[type_name] ;
if ($ref_type_id==$type_id) {
echo "<option value = '$type_id' selected>$type_name</option>" ;
} else {
echo "<option value = '$type_id'>$type_name</option> " ;
}
}
?>
</select>
<font color="#FF0000">*</font></p> </td>
</tr>
<tr>
<td align=lift valign=top bgcolor="#FFFFFF" ><p align="right" class="p style1">รายละเอียดสินค้า
:</p></td>
<td align=lift valign=top><p align="left" class="p">
<textarea name="product_detail" rows="4" cols="40" id="product_detail"><? echo $product_detail; ?> </textarea>
<font color="#FF0000">*</font></p></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" ><p align="right" class="p style1">ราคาสินค้า
:</p></td>
<td ><p align="left" class="p">
<input name = "product_price" type = "text" id="product_price" onkeypress= "check_number();" value="<? echo $product_price; ?> " size = "20" maxlength="10">
บาท <font color="#FF0000">*</font> </p></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" ><p align="right" class="p style1">จำนวนสินค้า
:</p></td>
<td > <p align="left" class="p"><input name = "product_stock" type = "text" id="product_stock" onkeypress= "check_number();" value="<? echo $stock ;?> " size = "20" maxlength="7"> ชิ้น </p></td>
</tr>
<tr>
<td align=lift valign=top bgcolor="#FFFFFF" ><p align="right" class="p style1">รูปภาพสินค้า
:</p></td>
<td><input type="file" name="filUpload"><br>
<?
if($hidAction == "Add") { //เช็คค่า hidden ที่่ส่งมา ถ้าเท่ากับ Add ให้โปรแกรมทำงาน
$date = date("U"); //สร้างเลข 10 หลักมาจากเวลา เพื่อเอาไปใช้เป็นชื่อของรูป ป้องกันชื่อรูปซ้ำ
if($file != "") {
$type = getimagesize($file); //หาประเภทของรูปภาพ
if($type[3] == 1) { //เมื่อรูปภาพเป็นชนิด gif
$picture= $date."_img.gif";
} else if($type[3] == 2) { //เมื่อรูปภาพเป็นชนิด jpg
$picture = $date."_img.jpg";
} else if($type[3] == 3) { //เมื่อรูปภาพเป็นชนิด jpg
$picture = $date."_img.bmp";
}
copy($file, "picture/$picture"); //ก๊อปปี้รูปภาพไปยังโพลเดอร์ images
chmod("picture/$picture", 0777); //ทำการ changmode
}

$host="localhost";
$db_username="root";
$db_password="1234";
$dbname="db_web"; //ชื่อฐานข้อมูล
$connect = mysql_connect($host,$db_username,$db_password);
if(!$connect){
echo "ไม่สามารถติดต่อฐานข้อมูลได้"; exit();
}

$sql = "insert into picture (id, picture) values ('', '$picture') "; //เพิ่มข้อมูลลงดาต้าเบส โดนเอาชื่อของรูปไปเก็บไว้
$dbquery = mysql_db_query($dbname, $sql);
;

}
?>
<input name = "id_prd_edit" type = "hidden" value ="<? echo $id_prd_edit ;?> " >
</tr>
<tr>
<td bgcolor="#FFFFFF" ><p align="right" class="p style1">แสดงหน้าแรก
:</p></td>
<td ><p align="left" class="p"><font color="#006699" size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">
<select name="status">
<?
if ($status == y){
echo(' <option value="y" selected>แสดง</option> ');
echo(' <option value="n">ไม่แสดง</option> ');
}else{
echo(' <option value="y">แสดง</option> ');
echo(' <option value="n" selected>ไม่แสดง</option> ');
}
?>
</select>
</font> </p></td>
</tr>
<tr>
<td><div align="center">
</div></td>
<td> <input type="button" name="Button" value=" ตกลง " onClick="check()">
<input type="reset" name="Reset" value="ยกเลิก">
<font size="1" face="MS Sans Serif, Tahoma, sans-serif">


</font> </td>
</tr>
</table>
</form></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td><p align="right" class="p">&nbsp;</p></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td align=lift valign=top>
<? include "button.php"; ?>
</td>
</tr>
</table></td>
<td width="17" background="images/bg_right.gif"><img src="images/bg_right.gif" width="17" height="16"></td>
</tr>
</table>
</body>
</html>



Tag : PHP, MySQL







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-02-29 17:21:37 By : ข้าวหอมมะลิ View : 718 Reply : 1
 

 

No. 1

Guest


อันนี้เป็นหน้า prd_edit2ค่ะ



<? include "chksession.php";?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>ผู้ดูแลระบบ</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="../style.css" rel="stylesheet" type="text/css">
</head>
<body leftmargin=0 topmargin=0 bgcolor="#BFA487">
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="17" background="images/bg_left.gif"><img src="images/bg_left.gif" width="17" height="16"></td>
<td width="780" align=lift valign=top><table width="780" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align=lift valign=top>
<? include "menu.php"; ?>
</td>
</tr>
<tr>
<td height="20" align=lift valign=top><table width="780" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="200" height="20" align=lift valign=top>
<? include "menu_left.php"; ?>
</td>
<td width="580" align=lift valign=top><table width="550" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<table width="550" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><p align="left" class="p">&nbsp;</p></td>
</tr>
<tr>
<td><p align="center" class="p"><b>
<?
include("../connect.php");


$id_prd_edit=$_POST[id_prd_edit];
$product_id=$_POST[product_id];
$product_name=$_POST[product_name];
$product_detail=$_POST[product_detail];
$product_price=$_POST[product_price];
$product_stock=$_POST[product_stock];
$picture=$_POST[picture];
$status=$_POST[status];
$ref_type_id=$_POST[ref_type_id];
echo "<IMG SRC='picture/$picture'>";

/*
$picture =$_FILES['picture']['tmp_name'];
$picture_name =$_FILES['picture']['name'];
$picture_size =$_FILES['picture']['size'];
$picture_type =$_FILES['picture']['type'];

include("../connect.php");
if ($chkdel=="1"){
$sql2="update product set picture='' where product_id = '$id_prd_edit' ";
$result2= mysql_db_query ($db , $sql2) ;
$picture_del="../picture/".$picture_del ;
if (file_exists ($picture_del) ){
unlink($picture_del) ;
}
}
if (!$picture) {
echo (' ไม่สามารถ Upload รูปภาพได้ครับ <br>
');
}
else
{
$array_last=explode (".", $picture_name) ;
$c=count ($array_last)-1;
$lastname=strtolower ($array_last [$c]);
if ($lastname=="gif" or $lastname=="jpg" or $lastname=="jpeg") {
copy ($picture, "../picture/".$picture_name) ;
echo (' เพิ่มรูปภาพเรียบร้อยแล้วครับ
');
$sql3="update product set picture='$picture_name' where product_id ='$id_prd_edit' ";
mysql_db_query ($db,$sql3);
}
else
{
echo (' เฉพาะรูปภาพนามสกุล *.gif, *.jpg, *.jpeg เท่านั้น
<meta http-equiv="refresh" content="2;URL=prd_display.php">
');
}
unlink($picture);
} */
$sql4 = "update product set product_name='$product_name', product_detail='$product_detail',picture='$picture', product_price='$product_price' ,stock='$product_stock' ,status ='$status ' ,ref_type_id='$ref_type_id' where product_id = '$id_prd_edit' " ;
$result4 = mysql_db_query ($db , $sql4) ;
if($result4){

echo (' แก้ไขสินค้าเรียบร้อยแล้วครับ
<meta http-equiv="refresh" content="1;URL=prd_display.php">
');
} else {
echo (' ERROR : ไม่สามารถแก้ไขสินค้าได้ครับ
<meta http-equiv="refresh" content="2;URL=prd_display.php">
');
}
?>
</b></p></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td align=lift valign=top>
<? include "button.php"; ?>
</td>
</tr>
</table></td>
<td width="17" background="images/bg_right.gif"><img src="images/bg_right.gif" width="17" height="16"></td>
</tr>
</table>
</body>
</html>

ฝากด้วยนะคะ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-02-29 17:24:14 By : ข้าวหอมมะลิ
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
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 05
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 อัตราราคา คลิกที่นี่