|  |  | 
          
            | พอดีผมทำหน้าแก้ไขรูปภาพครับโดยเก็บข้อมูลไว้ในฐานข้อมูล ใช้ทำกับหน้าอื่นก็ได้ปกติแต่กับหน้านี้ดันมีปัญหาไม่เจอค่าที่ส่งไปครับ 
 Notice: Undefined index: img in D:\xampp\htdocs\web\login\saveedit-aboutme.php on line 19
 
 รบกวนช่วยเชคทีครับผมเชคทุกจุดแล้วก็คิดว่าน่าจะต้องถูกแล้วเพราะมันสามารถดึงข้อมูลรายชื่อมาได้แก้ไขข้อมูลรายชื่ออื่นได้แต่บอกว่าไม่เจอชื่อของตัวรูปภาพทั้งที่ผมใช้โค้ดเดียวกันทำกับอีกตัวก็ได้้ปกติครับ
 
 หน้า1
 Code (PHP)
 
 <?php include("header.php");
                      include("config.php");
                      $sql = "SELECT *  FROM tbl_aboutme  WHERE id_ab ";
                       $query = mysqli_query($conn,$sql);
                    ?>
<center>
                    <div class="container " style="margin-top:1%" >
                      <div class="row">
                        <h4 class="page-header">แก้ไขรายชื่อพนักงานในทีม </h4>
              					   <table  class="table table-hover table-striped w3-card-4 table-bordered  table-condensed" >
              					     <thead>
                					     <tr class="color"  >
                					       <th > <div align="center">ชื่อ </div></th>
                					       <th > <div align="center">ตำแหน่ง </div></th>
                                 <th > <div align="center">เบอร์โทร </div></th>
                                 <th > <div align="center">รูปภาพ </div></th>
                					       <th > <div align="center">Edit </div></th>
                					     </tr>
              					     </thead>
              					  </div>
                       </div>
                  <?php
                  while($result=mysqli_fetch_array($query,MYSQLI_ASSOC))
                  {
                  ?>
                    <tr>
                    <td><div ><?php echo $result["name_ab"];?></td>
                    <td><div><?php echo $result["position"];?></td>
                    <td><div><?php echo $result["tel"];?></td>
                    <td>
                      <img class="img-responsive " src="../images/<?php echo $result["img"];?>"  width="100" height="100" >
                    </td>
                    <div class="form-group" >
                        <div class="col-md-12">
                          <input type="hidden" name="OldFileimg" id = "OldFileimg" value="<?php echo $result["img"];?>">
                      <td align="center"><a id="edit<?php echo $i;?>" class="various iframe" href="form-edit-aboutme.php?id_ab=<?php echo $result["id_ab"];?>">Edit</a></td>
                        </div>
                    </div>
                    </tr>
                  <?php
                  }
                  ?>
                </table>
</center>
<?php include("footer.php"); ?>
 หน้า2
 Code (PHP)
 
 <html>
<head>
<title>WDbus</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="">
<meta name="author" content="">
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
</head>
<body>
<form action="saveedit-aboutme.php?id_ab=<?php echo $_GET["id_ab"];?>" name="frmEdit" method="post">
<?php
    include("config.php");
$strSQL = "SELECT * FROM tbl_aboutme  WHERE id_ab = '".$_GET["id_ab"]."'  ";
 $objQuery = mysqli_query($conn,$strSQL);
$objResult = mysqli_fetch_array($objQuery,MYSQLI_ASSOC);
if(!$objResult)
{
	echo "Not found id_ab=".$_GET["id_ab"];
}
else
{
?>
<div class="container"  style="margin-top:1%" >
<table class="table table-hover table-striped w3-card-4">
  <tr style="background-color:#00BFFF">
    <th > <div align="center">ชื่อ </div></th>
    <th > <div align="center">ตำแหน่ง </div></th>
    <th > <div align="center">เบอร์โทร </div></th>
    <th > <div align="center">รูป </div></th>
    <th > <div align="center">เลือกรูปใหม่ </div></th>
  </tr>
       </div>
  <tr>
    <td><div ><input class="form-control text-center"  type="text" name="txtname" size="20" value="<?php echo $objResult["name_ab"];?>"></div></td>
    <td><div align="center"><input class="form-control text-center"  type="text" name="txtposition" size="20" value="<?php echo $objResult["position"];?>"></td>
    <td><div align="center"><input class="form-control text-center"  type="text" name="txttel" size="20" value="<?php echo $objResult["tel"];?>"></td>
    <td >
      <img src="../images/<?php echo $objResult["img"]; ?>" width="80px" height="80px" >
    </td>
      <td>
    <div align="center">  <input  type="file" name="img" id="img"  accept="image/*"  > </div>
        </td>
        */
  </tr>
  </table>
  <button align="center" class="w3-btn w3-blue w3-round-large" type="edit" name="edit" value="edit" >Edit</button></p>
  <?php
  }
  mysqli_close($conn);
  ?>
  </form>
</body>
</html>
 หน้า3หน้าเซฟข้อมูล
 Code (PHP)
 
 <html>
<head>
<title>WDBus</title>
</head>
<body>
<?php
	    include("config.php");
	$strSQL = "UPDATE tbl_aboutme SET ";
	$strSQL .="name_ab = '".$_POST["txtname"]."' ";
	$strSQL .=",position = '".$_POST["txtposition"]."' ";
	$strSQL .=",tel = '".$_POST["txttel"]."' ";
$strSQL .= "WHERE id_ab = '".$_GET["id_ab"]."'";
if($_FILES["img"]["name"] != "")
	{
		if(move_uploaded_file($_FILES["img"]["tmp_name"],"../images/".$_FILES["img"]["name"]))
		{
			//*** Delete Old File ***//
			@unlink("../images/".$_POST["OldFileimg"]);
			//*** Update New File ***//
			$strSQL = "UPDATE tbl_aboutme ";
			$strSQL .=" SET img = '".$_FILES["img"]["name"]."' WHERE id_ab = '".$_GET["id_ab"]."' ";
			$result =  mysqli_query($conn, $strSQL)or die ("Error in query: $strSQL " .mysqli_error($conn));
		}
	}
	if($result)
	{
		echo "<script type='text/javascript'>";
		echo  "alert('แก้ไขเรียบร้อย');";
		echo "window.location='edit-aboutme.php';";
		echo "</script>";
	}
	else
	{
		echo "<center>Error Save [".$strSQL."]</center>";
	}
	mysqli_close($conn);
?>
</body>
</html>
 
 
 Tag : PHP, HTML, HTML5, Bootstrap Framework
 
 
 |  
            |  |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2017-09-06 10:26:23 | By :
                          stamp006 | View :
                          661 | Reply :
                          2 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |