ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ThaiSEOBoard.comพัฒนาเว็บไซต์Programming>> สอบถาม PHP ครับ รบกวนด้วยครับ <<
หน้า: [1]   ลงล่าง
พิมพ์
ผู้เขียน หัวข้อ: >> สอบถาม PHP ครับ รบกวนด้วยครับ <<  (อ่าน 1625 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
bankker6480
สมุนแก๊งเสียว
*

พลังน้ำใจ: 162
ออฟไลน์ ออฟไลน์

กระทู้: 710



ดูรายละเอียด เว็บไซต์
« เมื่อ: 15 มกราคม 2013, 15:22:46 »

คือว่าผมลอง Add สินค้าแล้วมัน Add ไม่ได้อ่ะครับ ไม่รู้ว่าผิดตรงไหน wanwan011

โค้ดส่วนที่เกี่ยวข้องทั้งหมดครับ

Addproduct.html
โค๊ด:
<!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=windows-874" />
<title>เพิ่มรายการสินค้า</title>
<style type="text/css">
<!--
body {
background-color: #FFFFFF;
}
-->
</style>
<script type="text/javascript">
function senddata()
{

if ( document.getElementById('PID').value.length == 0 )
{
alert( 'ระบุรหัสสินค้าดัวยนะค่ะ' ) ;
return false ;
}
document.getElementById('submit').disabled = true ;

return true ;
}
function AddOk(pathfile)
{
document.getElementById('fileupload').value ="";
document.getElementById('showdetail').innerHTML = 'เพิ่มข้อมูลเสร็จเรียบร้อยแล้ว';
document.getElementById('submit').disabled = false;
document.getElementById('AddPForm').reset() ;
return true ;
}
</script>
<script type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i  )
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j  ].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i  ) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p 1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i  ) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i  ) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i =3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j  ]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i 2];}
}
//-->
</script>
</head>

<body onload="MM_preloadImages('./image/mbAddbook.gif','./image/mbEditbook.gif','./image/mbdelbook.gif','./image/mbSearchbook.gif','./image/mbBorrowbook.gif','./image/mbMoney.gif','./image/mbReMaAll.gif','./image/mbReMaTy.gif','./image/mbRebookSe.gif','image/mbook.gif','image/mMaster1.gif','image/mReport1.gif','image/mbook1.gif')">
<center>
<table width="837" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="134" rowspan="2" valign="top"><img src="./image2/Ntopleft.gif" width="134" height="142" /></td>
    <td height="97" colspan="2" valign="top"><img src="./image2/Ntopleft2.gif" alt="" width="56" height="103" /><a href="Addproduct.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image10','','image/mbook1.gif',1)"><img src="image/mbook1.gif" alt="" name="Image10" width="113" height="103" border="0" id="Image10" /></a><a href="Editproduct.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image11','','image/mMaster1.gif',1)"><img src="image/mMaster.gif" alt="" name="Image11" width="94" height="103" border="0" id="Image11" /></a><a href="Removeproduct.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image12','','image/mReport1.gif',1)"><img src="image/mReport.gif" alt="" name="Image12" width="118" height="103" border="0" id="Image12" /></a><img src="./image2/topmid2.gif" width="277" height="103" /></td>
    <td width="35">&nbsp;</td>
  </tr>
  <tr>
    <td width="4" height="36">&nbsp;</td>
    <td width="664" rowspan="2" valign="top"><p><img src="./image2/mid12.jpg" width="115" height="64" /><img src="./image2/mid2.jpg" width="92" height="65" /><img src="./image2/mid2.jpg" width="97" height="65" /><img src="./image2/mid2.jpg" width="98" height="65" /><img src="./image2/mid2.jpg" width="105" height="65" /><img src="./image2/mid3.jpg" width="130" height="65" /></p></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td rowspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <!--DWLayoutTable-->
      <tr>
        <td height="29" colspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
        </tr>
      <tr>
        <td height="29" colspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
        </tr>
      <tr>
        <td height="29" colspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
        </tr>
      <tr>
        <td width="33" height="2"></td>
        <td width="67"></td>
      </tr>
     
     
     
     
     
     
     
    </table></td>
    <td height="30"></td>
    <td></td>
  </tr>
 
 
  <tr>
    <td height="26"></td>
    <td><iframe id="uploadtarget" name="uploadtarget" src="" style="width:0px;height:0px;border:0"></iframe>
      <form id="AddPForm" method="post" enctype="multipart/form-data" action="Addproduct.php" onsubmit="return senddata();" target="uploadtarget">
        <h3>
          <p align="center">เพิ่มข้อมูลสินค้า </p>
        </h3>
        <table width="331" border="0" align="center">
          <tr>
            <td width="103">รหัสสินค้า  :</td>
            <td width="218"><div align="left">
              <input name="PID" type="text" id="PID" />
            </div></td>
          </tr>
          <tr>
            <td>ชื่อสินค้า :
              <label for="textfield"></label></td>
            <td><div align="left">
              <input type="text" name="Pname" id="Pname" />
            </div></td>
          </tr>
          <tr>
            <td>ราคา :
              <label for="label"></label></td>
            <td><div align="left">
              <input type="text" name="Pprice" id="Pprice" />
            </div></td>
          </tr>
          <tr>
            <td>ภาพสินค้า : </td>
            <td><div align="left">
              <input type="file" name="fileupload" id="fileupload" />
            </div></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><div align="left">
              <input name="submit" type="submit" value="submit" id="submit"/>
              <input type="reset" name="Reset" value="Reset" id="Reset" />
            </div></td>
          </tr>
        </table>
        <p align="center">
          <label for="Submit"></label>
        </p>
    </form></td>
    <td></td>
  </tr>
  <tr>
    <td height="307"></td>
    <td rowspan="2" align="center" valign="top"><span id="showdetail" ></span></td>
    <td></td>
  </tr>
  <tr>
    <td height="162">&nbsp;</td>
    <td></td>
    <td></td>
  </tr>
</table>
</center>
</body>
</html>

<?php
mysql_free_result
($Sbooktype);
?>


AddData.php

โค๊ด:
   <?php
include ("config.inc.php");
$realname $HTTP_POST_FILES[&#39;fileupload&#39;][&#39;name&#39;];
$str=substr($realname,-3,3);
  if (
is_uploaded_file($HTTP_POST_FILES[&#39;fileupload&#39;][&#39;tmp_name&#39;]) )
  
{
     
copy($HTTP_POST_FILES[&#39;fileupload&#39;][&#39;tmp_name&#39;], "./image/book/$realname");
$Url="image/book/$realname";
 $Filename=$HTTP_POST_FILES[&#39;fileupload&#39;][&#39;name&#39;];
 $size=$HTTP_POST_FILES[&#39;fileupload&#39;][&#39;size&#39;]/1024/1024;
$size1=number_format($size,3);
  } else{
     echo 
" Upload not complete";
   } ;
$sql=" INSERT INTO product (ID,name,price,pic) values (&#39;$PID&#39;,&#39;$Pname&#39;,&#39;$Pprice&#39;,&#39;$Url&#39;)";
mysql_db_query($DBName,"SET NAMES tis620");
$sqlquery=mysql_db_query($DBName,$sql) or die("&#3652;&#3617;&#3656;&#3626;&#3634;&#3617;&#3634;&#3619;&#3606;&#3648;&#3614;&#3636;&#3656;&#3617;&#3586;&#3657;&#3629;&#3617;&#3641;&#3621;&#3652;&#3604;&#3657; &#3585;&#3619;&#3640;&#3603;&#3634;&#3605;&#3619;&#3623;&#3592;&#3626;&#3629;&#3610;&#3586;&#3657;&#3629;&#3617;&#3641;&#3621;&#3629;&#3637;&#3585;&#3588;&#3619;&#3633;&#3657;&#3591;");
mysql_close();
print
"&#3648;&#3614;&#3636;&#3656;&#3617;&#3586;&#3657;&#3629;&#3617;&#3641;&#3621;&#3648;&#3619;&#3637;&#3618;&#3610;&#3619;&#3657;&#3629;&#3618;&#3649;&#3621;&#3657;&#3623;";
?>

<script language="JavaScript">
<!--
window.parent.AddOk('<?=$Pname?>');
//-->
</script>

Editproduct.php
โค๊ด:
<? 
header("Content-Type: text/plain; charset=TIS-620");
session_start();
$sessionID= session_id();
$removeProductID = $_POST['productID'];
?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
background-color: #FFFFFF;
}
-->
</style>
<script type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i  )
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j  ].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i  ) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p 1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i  ) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i  ) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i =3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j  ]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i 2];}
}
//-->
</script>
</head>

<body onLoad="MM_preloadImages('./image/mbAddbook.gif','./image/mbEditbook.gif','./image/mbdelbook.gif','./image/mbSearchbook.gif','./image/mbBorrowbook.gif','./image/mbMoney.gif','./image/mbReMaAll.gif','./image/mbReMaTy.gif','./image/mbRebookSe.gif','image/mbook.gif','image/mMaster1.gif','image/mReport1.gif','image/mbook1.gif')">
<table width="1008" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="134" rowspan="2" valign="top"><img src="./image2/Ntopleft.gif" width="134" height="142" /></td>
    <td height="97" colspan="2" valign="top"><img src="./image2/Ntopleft2.gif" alt="" width="56" height="97" /><a href="Addproduct.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image10','','image/mbook1.gif',1)"><img src="image/mbook.gif" alt="" name="Image10" width="113" height="96" border="0" id="Image10" /></a><a href="Editproduct.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image11','','image/mMaster1.gif',1)"><img src="image/mMaster1.gif" alt="" name="Image11" width="94" height="97" border="0" id="Image11" /></a><a href="Removeproduct.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image12','','image/mReport1.gif',1)"><img src="image/mReport.gif" alt="" name="Image12" width="118" height="97" border="0" id="Image12" /></a><img src="./image2/topmid2.gif" alt="" width="277" height="97" /></td>
    <td width="100">&nbsp;</td>
  </tr>
  <tr>
    <td width="4" height="36">&nbsp;</td>
    <td width="770" rowspan="2" valign="top"><p><img src="./image2/mid12.jpg" width="115" height="64" /><img src="./image2/mid2.jpg" width="110" height="66" /><img src="./image2/mid2.jpg" width="110" height="66" /><img src="./image2/mid2.jpg" width="104" height="66" /><img src="./image2/mid2.jpg" width="103" height="66" /><img src="./image2/mid3.jpg" width="116" height="66" /></p></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td rowspan="3" valign="top" ><!--DWLayoutEmptyCell-->&nbsp;</td>
    <td height="30"></td>
    <td></td>
  </tr>
 
 
  <tr>
    <td height="26"></td>
    <td><br><?
include ("config.inc.php");
if ($ProductID>0){
$sql = "UPDATE `shoponline`.`product`
SET `name` = '$Pname',
`price` = '$Pprice'
WHERE `product`.`ID` ='$ProductID' ;";
mysql_query($sql);
}
$sql = "SELECT * FROM `product`";
$result = mysql_query($sql);
$totalPrice=0;
echo"<table width='75%' border='1' bordercolor='#A59A1B'  bgcolor='#D3BC38' ><tr align='center'><td><b>ภาพสินค้า</b></td>
<td> <b>รหัสสินค้า</b></td>
<td> <b>ชื่อสินค้า</b></td>
<td><b>ราคา</b></td>
<td><b>แก้ไขสินค้า</b>
<td><b></b>
</td></tr>";
while($row=mysql_fetch_array($result)){
$ProductID = $row["ID"];
$productName = $row["name"];
$productPrice = $row["price"];
$pic = $row["pic"];
echo "<tr bgcolor='#D3BC38' align='center'><form id='form1' name='form1' method='post' action='Editproduct.php'>";
echo"<td><img src='$pic'></td>";
echo "<td>$ProductID<input name='ProductID' type='hidden' value='$ProductID'></td><td><input name='Pname' type='text' value='$productName'></td>";
echo "<td><input name='Pprice' type='text' value='$productPrice บาท'></td>";
echo "<td><input type='submit' name='Delete' id='Edit'  value='Edit' onclick=" ?>"return confirm('คุณแน่ใจว่าต้องการแก้ไขข้อมูลนี้หรือไม่ ? ')" /><? "/>";
echo "</td></form></tr>";
}
echo "</table>";
?></br></td>
    <td></td>
  </tr>
  <tr>
    <td height="29" ></td>
    <td rowspan="2">
     
    <h3 align="left">&nbsp;</h3></td>
    <td></td>
  </tr>
  <tr>
 
 
  </tr>
</table>
</body>
</html>


Removeproduct.php
โค๊ด:
<? 
header("Content-Type: text/plain; charset=TIS-620");
session_start();
$sessionID= session_id();
$removeProductID = $_POST['productID'];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
background-color: #FFFFFF;
}
-->
</style>
<script type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i  )
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j  ].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i  ) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p 1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i  ) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i  ) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i =3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j  ]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i 2];}
}
//-->
</script>
</head>

<body onLoad="MM_preloadImages('./image/mbAddbook.gif','./image/mbEditbook.gif','./image/mbdelbook.gif','./image/mbSearchbook.gif','./image/mbBorrowbook.gif','./image/mbMoney.gif','./image/mbReMaAll.gif','./image/mbReMaTy.gif','./image/mbRebookSe.gif','image/mbook.gif','image/mMaster1.gif','image/mReport1.gif','image/mbook1.gif')">
<table width="853" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="134" rowspan="2" valign="top"><img src="./image2/Ntopleft.gif" width="134" height="142" /></td>
    <td height="97" colspan="2" valign="top"><img src="./image2/Ntopleft2.gif" alt="" width="56" height="97" /><a href="Addproduct.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image10','','image/mbook1.gif',1)"><img src="image/mbook.gif" alt="" name="Image10" width="113" height="96" border="0" id="Image10" /></a><a href="Editproduct.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image11','','image/mMaster1.gif',1)"><img src="image/mMaster.gif" alt="" name="Image11" width="94" height="97" border="0" id="Image11" /></a><a href="Removeproduct.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image12','','image/mReport1.gif',1)"><img src="image/mReport1.gif" alt="" name="Image12" width="118" height="97" border="0" id="Image12" /></a><img src="./image2/topmid2.gif" alt="" width="277" height="97" /></td>
    <td width="30">&nbsp;</td>
  </tr>
  <tr>
    <td width="4" height="36">&nbsp;</td>
    <td width="685" rowspan="2" valign="top"><p><img src="./image2/mid12.jpg" width="115" height="64" /><img src="./image2/mid2.jpg" width="89" height="66" /><img src="./image2/mid2.jpg" width="110" height="66" /><img src="./image2/mid2.jpg" width="104" height="66" /><img src="./image2/mid2.jpg" width="111" height="66" /><img src="./image2/mid3.jpg" width="134" height="66" /></p></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td rowspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <!--DWLayoutTable-->
      <tr>
        <td height="29" colspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
        </tr>
      <tr>
        <td height="29" colspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
        </tr>
      <tr>
        <td height="29" colspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
        </tr>
      <tr>
        <td width="33" height="2"></td>
        <td width="67"></td>
      </tr>
     
     
     
     
     
     
     
    </table></td>
    <td height="30"></td>
    <td></td>
  </tr>
 
 
  <tr>
    <td height="26"></td>
    <td><?
include ("config.inc.php");
if ($ProductID>0){
$sql = "Delete from product where ID=$ProductID";
mysql_query($sql);
}
$sql = "SELECT * FROM `product`";
$result = mysql_query($sql);
$totalPrice=0;
echo"<table width='80%' border='1' bordercolor='#A59A1B'  bgcolor='#D3BC38' ><tr align='center'><td><b>ภาพสินค้า</b></td>
<td> <b>รหัสสินค้า</b></td>
<td> <b>ชื่อสินค้า</b></td>
<td><b>ราคา</b></td>
<td><b>ลบสินค้า</b>
<td><b></b>
</td></tr>";
while($row=mysql_fetch_array($result)){
$ProductID = $row["ID"];
$productName = $row["name"];
$productPrice = $row["price"];
$pic = $row["pic"];
echo "<tr bgcolor='#D3BC38' align='center'><form id='form1' name='form1' method='post' action='Removeproduct.php'>";
echo"<td><img src='$pic'></td>";
echo "<td>$ProductID<input name='ProductID' type='hidden' value='$ProductID'></td><td>$productName</td>";
echo "<td>$productPrice บาท</td>";
echo "<td><input type='submit' name='Delete' id='Delete'  value='Delete' onclick=" ?>"return confirm('คุณแน่ใจว่าต้องการลบข้อมูลนี้หรือไม่ ? ')" /><? "/>";
echo "</td></form></tr>";
}
echo "</table>";
?></td>
    <td></td>
  </tr>
  <tr>
    <td height="307"></td>
    <td rowspan="2">
     
    <h3 align="left">&nbsp;</h3></td>
    <td></td>
  </tr>
  <tr>
    <td height="162">&nbsp;</td>
    <td></td>
    <td></td>
  </tr>
</table>
</body>
</html>



MainAdmin.php
โค๊ด:
<!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-Language" content="th">
<meta http-equiv="content-Type" content="text/html; charset=window-874">
<meta http-equiv="content-Type" content="text/html; charset=tis-620">
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
background-color: #FFFFFF;
}
-->
</style>
<script type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i  )
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j  ].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i  ) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p 1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i  ) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i  ) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i =3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j  ]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i 2];}
}
//-->
</script>
</head>

<body onload="MM_preloadImages('./image/mbAddbook.gif','./image/mbEditbook.gif','./image/mbdelbook.gif','./image/mbSearchbook.gif','./image/mbBorrowbook.gif','./image/mbMoney.gif','./image/mbReMaAll.gif','./image/mbReMaTy.gif','./image/mbRebookSe.gif','image/mbook.gif','image/mMaster1.gif','image/mReport1.gif')">
<table width="1008" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="100" rowspan="2" valign="top"><img src="./image2/Ntopleft.gif" width="134" height="142" /></td>
    <td height="97" colspan="2" valign="top"><img src="./image2/Ntopleft2.gif" width="56" height="97" /><a href="AddProduct.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image10','','image/mbook1.gif',1)"><img src="image/mbook.gif" name="Image10" width="113" height="96" border="0" id="Image10" /></a><a href="Editproduct.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image11','','image/mMaster1.gif',1)"><img src="image/mMaster.gif" name="Image11" width="94" height="97" border="0" id="Image11" /></a><a href="Removeproduct.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image12','','image/mReport1.gif',1)"><img src="image/mReport.gif" name="Image12" width="118" height="97" border="0" id="Image12" /></a><img src="./image2/topmid2.gif" width="277" height="97" /></td>
    <td width="11">&nbsp;</td>
  </tr>
  <tr>
    <td width="3" height="36">&nbsp;</td>
    <td rowspan="2" valign="top"><p><img src="./image2/mid12.jpg" width="115" height="64" /><img src="./image2/mid2.jpg" width="99" height="66" /><img src="./image2/mid2.jpg" width="102" height="66" /><img src="./image2/mid2.jpg" width="104" height="66" /><img src="./image2/mid2.jpg" width="111" height="66" /><img src="./image2/mid3.jpg" width="120" height="65" /></p></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td rowspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <!--DWLayoutTable-->
      <tr>
        <td height="29" colspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
        </tr>
      <tr>
        <td height="29" colspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
        </tr>
      <tr>
        <td height="29" colspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
        </tr>
      <tr>
        <td width="33" height="2"></td>
        <td width="67"></td>
      </tr>
     
     
     
     
     
     
     
    </table></td>
    <td height="30"></td>
    <td></td>
  </tr>
 
 
  <tr>
    <td height="26"></td>
    <td><?
include ("config.inc.php");
$sql = "SELECT * FROM `product`";
$result = mysql_query($sql);
$totalPrice=0;
echo"<table width='75%' border='1' bordercolor='#A59A1B'  bgcolor='#D3BC38' ><tr align='center'><td><b>ภาพสินค้า</b></td>
<td> <b>รหัสสินค้า</b></td>
<td> <b>ชื่อสินค้า</b></td>
<td><b>ราคา</b></td>
<td><b></b>
</td></tr>";
while($row=mysql_fetch_array($result)){
$ProductID = $row["ID"];
$productName = $row["name"];
$productPrice = $row["price"];
$pic = $row["pic"];
echo "<tr bgcolor='#D3BC38' align='center'>";
echo"<td><img src='$pic'></td>";
echo "<td>$ProductID</td><td>$productName</td>";
echo "<td>$productPrice บาท</td>";
echo "</tr>";
}
echo "</table>";
?></td>
    <td></td>
  </tr>
  <tr>
    <td height="307"></td>
    <td rowspan="2">
     
    <h3 align="left">&nbsp;</h3></td>
    <td></td>
  </tr>
  <tr>
    <td height="162">&nbsp;</td>
    <td></td>
    <td></td>
  </tr>
</table>
</body>
</html>

<?php
mysql_free_result
($Sbooktype);
?>

config.inc.php
โค๊ด:
<?php
$DBServer 
"localhost";
$DBName " *** ";
$DBUsername " *** ";
$DBPassword " *** ";
$conn mysql_connect($DBServer$DBUsername $DBPassword ) or die("Could not connect to dbserver");
?>

 
« แก้ไขครั้งสุดท้าย: 15 มกราคม 2013, 16:50:52 โดย bankker6480 » บันทึกการเข้า
Etaba
ก๊วนเสียว
*

พลังน้ำใจ: 16
ออฟไลน์ ออฟไลน์

กระทู้: 207



ดูรายละเอียด
« ตอบ #1 เมื่อ: 15 มกราคม 2013, 15:24:11 »

มี error ไร บอกไหมครับ
บันทึกการเข้า
bankker6480
สมุนแก๊งเสียว
*

พลังน้ำใจ: 162
ออฟไลน์ ออฟไลน์

กระทู้: 710



ดูรายละเอียด เว็บไซต์
« ตอบ #2 เมื่อ: 15 มกราคม 2013, 15:26:45 »

ไม่มีบอกเลยครับ แต่กด submit ไม่ได้อ่ะครับ

http://bank-network.info/AddProduct.html
บันทึกการเข้า
ICheer_No0M
Newbie
*

พลังน้ำใจ: 13
ออฟไลน์ ออฟไลน์

กระทู้: 78



ดูรายละเอียด เว็บไซต์
« ตอบ #3 เมื่อ: 15 มกราคม 2013, 15:31:14 »

action="Addproduct.php" <== ไปผิดที่หรือเปล่าครับ ไฟล์ชื่อ AddData.php ไม่ใช่เหรอครับ
บันทึกการเข้า

aommiez
ก๊วนเสียว
*

พลังน้ำใจ: 13
ออฟไลน์ ออฟไลน์

กระทู้: 302



ดูรายละเอียด
« ตอบ #4 เมื่อ: 15 มกราคม 2013, 15:33:02 »

http://bank-network.info/Addproduct.php

Request Method:POST
Status Code:404 Not Found

มันซับมิตไปหาไฟล์ Addproduct.php แต่มันไม่เจอไฟล์
บันทึกการเข้า
bankker6480
สมุนแก๊งเสียว
*

พลังน้ำใจ: 162
ออฟไลน์ ออฟไลน์

กระทู้: 710



ดูรายละเอียด เว็บไซต์
« ตอบ #5 เมื่อ: 15 มกราคม 2013, 15:43:30 »

ขอบคุณครับ
โค๊ด:
<form id="AddPForm" method="post" enctype="multipart/form-data" action="AddData.php" onsubmit="return senddata();" target="uploadtarget">

เปลี่ยนแล้วแต่ก็ยัง Add ไม่ได้ครับ wanwan011
บันทึกการเข้า
adidog
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 238
ออฟไลน์ ออฟไลน์

กระทู้: 1,858



ดูรายละเอียด เว็บไซต์
« ตอบ #6 เมื่อ: 15 มกราคม 2013, 15:46:39 »

add.php

ใส่

ini_set('display_errors', 1);
error_reporting(E_ALL);

บรรทัดบนสุดดูครับ จะได้รู้ว่าเพราะอะไร
บันทึกการเข้า

Certain Dri Certain Dri
คุณแม่มือใหม่ คุณแม่มือใหม่
ICheer_No0M
Newbie
*

พลังน้ำใจ: 13
ออฟไลน์ ออฟไลน์

กระทู้: 78



ดูรายละเอียด เว็บไซต์
« ตอบ #7 เมื่อ: 15 มกราคม 2013, 15:47:22 »

ไฟล์ Addproduct.php อยู่ที่ path เดียวกับ AddProduct.html ด้วยนะครับ

Request URL:http://bank-network.info/Addproduct.php
Request Method:POST
Status Code:404 Not Found



ปล. ทำไมไม่เห็นมีการรับค่า $_POST มาเลยล่ะครับ Shocked

เห็นแต่ในส่วนของ upload
« แก้ไขครั้งสุดท้าย: 15 มกราคม 2013, 15:48:08 โดย ICheer_No0M » บันทึกการเข้า

aunkanbin
สมุนแก๊งเสียว
*

พลังน้ำใจ: 226
ออฟไลน์ ออฟไลน์

กระทู้: 538



ดูรายละเอียด เว็บไซต์
« ตอบ #8 เมื่อ: 15 มกราคม 2013, 15:58:25 »

ไฟล์
อ้างถึง
มัน 404 Not Found ครับ
ต้องอัปโหลดไฟล์นั้นขึ้นไปด้วยครับหรือถ้ามีแล้วก็ rename เป็นชื่อนั้นครับ
ถ้าจะให้แนาะนำซื้อหนังสือ PHP พื้นฐานมาซักเล่มแล้วนั่งอ่านอาทิตย์นึงก็เป็นแล้วครับ  Tongue
บันทึกการเข้า

ยิ่งสูงยิ่งหนาว
gubaaball
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 184
ออฟไลน์ ออฟไลน์

กระทู้: 1,678



ดูรายละเอียด เว็บไซต์
« ตอบ #9 เมื่อ: 15 มกราคม 2013, 16:18:57 »

ผมว่ามันไปหยุดที่ function senddata() หรือป่าวครับ ท่านจะใช้อัปโหลดไฟล์กึ่งๆ Ajax ใช่ไหมครับ ผมคุ้นๆ โค้ดนี้

และในหน้าประมวลผล php ก็ไม่ได้รับค่าตัวแปรน่ะครับ ผมว่าผิดเยอะเลยครับท่าน  Tongue
« แก้ไขครั้งสุดท้าย: 15 มกราคม 2013, 16:21:56 โดย gubaaball » บันทึกการเข้า

bankker6480
สมุนแก๊งเสียว
*

พลังน้ำใจ: 162
ออฟไลน์ ออฟไลน์

กระทู้: 710



ดูรายละเอียด เว็บไซต์
« ตอบ #10 เมื่อ: 15 มกราคม 2013, 16:26:10 »

ผมว่ามันไปหยุดที่ function senddata() หรือป่าวครับ ท่านจะใช้อัปโหลดไฟล์กึ่งๆ Ajax ใช่ไหมครับ ผมคุ้นๆ โค้ดนี้

และในหน้าประมวลผล php ก็ไม่ได้รับค่าตัวแปรน่ะครับ ผมว่าผิดเยอะเลยครับท่าน  Tongue

ผมงงไปหมดแล้วครับ เทพท่านไหนว่างๆช่วยผมแก้หน่อยครับ Cry
บันทึกการเข้า
aommiez
ก๊วนเสียว
*

พลังน้ำใจ: 13
ออฟไลน์ ออฟไลน์

กระทู้: 302



ดูรายละเอียด
« ตอบ #11 เมื่อ: 15 มกราคม 2013, 16:39:23 »

ผมว่านะ เอาโค๊ดที่เกี่ยวข้องโพสให้ดูหน่อยครับ
บันทึกการเข้า
bankker6480
สมุนแก๊งเสียว
*

พลังน้ำใจ: 162
ออฟไลน์ ออฟไลน์

กระทู้: 710



ดูรายละเอียด เว็บไซต์
« ตอบ #12 เมื่อ: 15 มกราคม 2013, 16:51:26 »

ผมว่านะ เอาโค๊ดที่เกี่ยวข้องโพสให้ดูหน่อยครับ

ผมอัพเพิ่มไปบนกระทู้ ข้างบนสุดแล้วครับ
บันทึกการเข้า
kuznetsova
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 137
ออฟไลน์ ออฟไลน์

กระทู้: 1,316



ดูรายละเอียด เว็บไซต์
« ตอบ #13 เมื่อ: 15 มกราคม 2013, 16:58:13 »

ผมว่านะ เอาโค๊ดที่เกี่ยวข้องโพสให้ดูหน่อยครับ

ผมอัพเพิ่มไปบนกระทู้ ข้างบนสุดแล้วครับ

ส่งตัวแปลแบบ get ไปที่ไฟล์ add.php ดูครับว่ามันทำงานได้หรือป่าว ถ้าทำงานได้
ให้ดูฟังก์ชันจาวา script ว่า error ป่าว ปกติผมจะใส่คำสั่ง alert อะไรสักอย่าง ที่ผมสงสัยว่าโค้ดมีปัญหา เพื่อให้เช็คว่ามันทำงานเข้า if ไหน
ประมาณนี้

ตอนแรกหาก่อนว่า มัน error php หรือ javascript
บันทึกการเข้า

gubaaball
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 184
ออฟไลน์ ออฟไลน์

กระทู้: 1,678



ดูรายละเอียด เว็บไซต์
« ตอบ #14 เมื่อ: 15 มกราคม 2013, 22:46:29 »

ไม่รู้ว่าได้หรือยังไปข้างนอกเพิ่งเข้ามา 55  ลองเอาโค้ดไปเทสแล้วครับ ปรากฎว่า ที่ไม่ขึ้นอะไรก็เพราะมี error ที่หน้านี้ครับ AddData.php

บรรทัดนี้น่ะครับ
$sql=" INSERT INTO product (ID,name,price,pic) values ('$PID','$Pname','$Pprice','$Url')";
mysql_db_query($DBName,"SET NAMES tis620");
$sqlquery=mysql_db_query($DBName,$sql) or die("ไม่สามารถเพิ่มข้อมูลได้ กรุณาตรวจสอบข้อมูลอีกครั้ง");

** มี error จากการ insert ข้อมูลลงดาต้าเบสแน่นอนครับ ถ้าท่านไม่เชื่อก็ตัด 3 บรรทัดนี้ออกไปเลยครับ สคริปต์จะทำงานได้ ส่วน error อะไรก็คงมีแต่ท่านเท่านั้นที่รู้ เพราะ db ท่านเป็นคนสร้างเอง

** บรรทัดนี้ ก็ตัดทิ้งไปครับ
โค๊ด:
print"เพิ่มข้อมูลเรียบร้อยแล้ว";

** แล้วก็ท่านต้องรับค่าตัวแปร POST ก่อนการ insert ข้อมูลลงดาต้าเบสน่ะครับ เช่น $Pname=$_POST['Pname']; และก็ทำทุกตัวที่บันทึกลงดาต้าเบส ผมเห็นท่านไม่ได้รับค่าตัวแปรก่อน

** ส่วนท่านจะให้มันรีเทริน์ข้อความอะไรออกมาแสดง ก็ให้ส่งค่าไปตรงนี้ window.parent.AddOk('<?=$Pname?>'); สมมติน่ะครับ ผมจะรีเทิร์นคำว่า "บันทึกข้อมูลเสร็จแล้ว" หากสามารถบันทึกข้อมูลได้ ผมจะเขียนโค้ดประมาณนี้ต่อจากการ insert ข้อมูลลงดาต้าเบสอย่างถูกต้อง

โค๊ด:

if($sqlquery){
  $tellme='บันทึกข้อมูลเสร็จแล้ว';
}else {
  $tellme='บันทึกข้อมูลล้มเหลว ตรวจสอบซะ';
}

<script language="JavaScript">
<!--
window.parent.AddOk('<?=$tellme;?>');
//-->
</script>

ซึ่งจากโค้ดข้างบนมันจะส่งค่ากลับไปยังหน้า Addproduct.html ในฟังก์ชัน function AddOk(pathfile) ซึ่งคำว่า pathfile คือชื่อตัวแปรเพื่อรับค่าตัวแปร $tellme จากหน้า AddData.php แล้วก็ในฟังก์ชัน AddOk ก็แก้เป็นอย่างนี้น่ะครับเพื่อให้แสดงผลตามที่เราต้องการ

โค๊ด:
function AddOk(pathfile)
{
document.getElementById('fileupload').value ="";
document.getElementById('showdetail').innerHTML = pathfile;
document.getElementById('submit').disabled = false;
document.getElementById('AddPForm').reset() ;
return true ;
}

และสุดท้าย โค้ดที่ท่านกำลังเขียนอยู่เหมือนว่าจะเป็นการ copy code มาโดยซะส่วนใหญ่โดยไม่รู้ว่าแต่ละบรรทัดมีไว้เพื่ออะไร ถ้าท่านมีเวลาน่ะครับแนะนำให้ศึกษา php เบื้องต้นก่อน เช่นการรับส่งค่าตัวแปร $_GET, $_POST, $_SESSION, $_COOKIES มันมีความหมายต่างกันอย่างไรบ้าง

ผิดถูกยังไงก็ขออภัยด้วยล่ะกันครับ  wanwan017
บันทึกการเข้า

หน้า: [1]   ขึ้นบน
พิมพ์