|
|
|
รบกวนช่วยดูโค้ดหน่อยค่ะ เราจะแก้ไขรูปภาพโดยการอัพโหลด ให้มันเข้าโฟลเดอร์ด้วยยังไงหรอคะ? |
|
|
|
|
|
|
|
หน้า edit_shop2 ค่ะ
Code (PHP)
<?php
include "connectDB/connectdb.php";
if($_GET['sid'] == ''){
header('Location: index.php');
exit;
}
//var_dump($_POST);
if(isset($_POST['submit']) == 'submit'){
$sid=$_POST['shopid'];
$sname=$_POST['shopname'];
$stel=$_POST['shoptel'];
$sadd=$_POST['shopadd'];
$sdesc=$_POST['shopdesc'];
$spoint=$_POST['shoppoint'];
// Upload File //
$name = '';
$uploads_dir='upload';
$file=$_FILES['file_img'];
if ($file['tmp_name']){
$tmp_name=$file["tmp_name"];
$name = $file["name"];
// $name = "images/".$file["name"];
move_uploaded_file($tmp_name,$uploads_dir,$name);
}
// Upload File //
$sql= mysql_query("
UPDATE shop SET
ShopID = '$sid',
ShopName = '$sname',
ShopTel = '$stel',
ShopAdd = '$sadd',
ShopDesc = '$sdesc',
ShopPoint = '$spoint',
ShopPic = '$name'
WHERE ShopID = '$sid'
");
}else{
//$sql =$db->query("SELECT * FROM shop WHERE ShopID= '".$_GET['sid']."'");
$sql = mysql_query("SELECT * FROM shop WHERE ShopID= '".$_GET['sid']."'");
// $row =$sql->fetch_assoc();
while($row = mysql_fetch_array($sql)){
$sid =$row['ShopID'];
$sname =$row['ShopName'];
$stel =$row['ShopTel'];
$sadd =$row['ShopAdd'];
$spic =$row['ShopPic'];
$sdesc =$row['ShopDesc'];
$spoint =$row['ShopPoint'];
}
}
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="page-header">
<h3>แก้ไขสมาชิก</h3>
</div>
<a href="index.php">หน้าแรก</a>
<form enctype="multipart/form-data" method="post" class="form-horizontal">
<div class="form-group">
<label class="col-sm-3 control-label">Shop Name</label>
<div class="col-sm-8">
<input type="hidden" name="shopid" value=<?php echo $sid;?> required>
<input type="text" class="form-control" name="shopname" value="<?php echo $sname;?>" required>
<span id="error_f"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Shop Tel</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="shoptel" value="<?php echo $stel;?>" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Address</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="shopadd" value="<?php echo $sadd;?>" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">รูปภาพ</label>
<div class="col-sm-9">
<input type="file" name="file_img"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">desc</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="shopdesc" value="<?php echo $sdesc;?>" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Shop Point</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="shoppoint" value="<?php echo $spoint;?>" required>
</div>
</div>
<div class="form-group">
<div class="col-sm-3">
<button type="submit" name="submit" id="submit" class="btn btn-default" value="submit">Save</button>
</div>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
หน้า edit_shop ค่ะ
Code (PHP)
<?php
include "connectDB/connectdb.php";
?>
<!DOCTYPE HTML>
<html>
<?php include "head.php";?>
<body>
<div class="container">
<div class="row">
<div class="header clearfix">
<h3 class="text-muted">แก้ไขร้านค้า</h3>
</div>
<a href="pages.php">กลับหน้าแรก</a>
<table class="table table-striped">
<tr class="text-center">
<td>#</td>
<td>ชื่อร้าน</td>
<!--<td>ShopTel</td>-->
<!--<td>ShopAdd</td>-->
<!--<td>ShopNamePic</td>-->
<td>รูปร้าน</td>
<!--<td>ShopTypePic</td>-->
<!--<td>ShopDesc</td>-->
<!--<td>ShopPoint</td>-->
</tr>
<?php
$sql = mysql_query("SELECT * FROM shop");
$n = 1;
while($row = mysql_fetch_array($sql)){
echo "<tr class='text-center'>";
echo "<td>".$n."</td>";
echo "<td>".$row['ShopName']."</td>";
//echo "<td>".$row['ShopTel']."</td>";
//echo "<td>".$row['ShopAdd']."</td>";
//echo "<td>".$row['ShopNamePic']."</td>";
//echo "<td>".$row['ShopPic']."</td>";
echo"<td>";?><img src="<?php echo $row["ShopPic"];?>" height="300" width="450"><?php echo "</td>";
//echo "<td>".$row['ShopTypePic']."</td>";
//echo "<td>".$row['ShopDesc']."</td>";
//echo "<td>".$row['ShopPoint']."</td>";
echo "<td><a href='edit_shop2.php?sid=".$row['ShopID']."'><span class='glyphicon glyphicon-pencil' aria-hidden='true'></span></a>";
echo "<a href='del_shop.php?sid=".$row['ShopID']."' onclick='return confirm(\"คุณแน่ใจหรือไม่ที่ต้องการลบ ?\");'><span class='glyphicon glyphicon-trash' aria-hidden='true'></span></a></td>";
echo "</tr>";
$n+=1;
}
?>
</table>
</div>
</div>
</body>
</html>
คือเพิ่มได้ปกติ แต่พอแก้ไขแล้วรูปไม่ขึ้นค่ะ คือคิดว่า ตอนแก้ไขรูปไม่เข้าโฟลเดอร์ TT รบกวนช่วยดูหน่อยะคะ TT
Tag : PHP, MySQL, HTML/CSS, jQuery
|
|
|
|
|
|
Date :
2015-11-22 22:39:33 |
By :
ryomaconz |
View :
704 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
บทความนี้ครับ
|
|
|
|
|
Date :
2015-11-23 10:01:55 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|