|
|
|
แก้ยังไง code มัน update ไม่ได้ ช่วยผนดว้ย ขอคำแนนำดว้ย หนดทางแก้แล้ว |
|
|
|
|
|
|
|
Code (PHP)
<?php
ob_start();
include('include/connect.php');
if(isset($_GET['id']))
{
$qry = "SELECT * FROM wtwo where id=".$_GET['id'];
$result = mysql_query($qry);
$row = mysql_fetch_array($result);
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$name = $_POST["name"];
$info = $_POST["infor"];
IF($_FILES['file']['name']!='')
{
$file='uploads/'.$row['image'];
@unlink($file);
$tmp_name = $_FILES["file"]["tmp_name"];
$namefile = $_FILES["file"]["name"];
$ext = end(explode(".", $namefile));
$image_name=time().".".$ext;
$fileUpload = move_uploaded_file($tmp_name,"uploads/".$image_name);
}
else
{
$image_name=$row['image'];
}
$sqlAdd ="update wtwo set name='".$name."', info='".$infor."', image='".$image_name."' where id=".$_GET['id'];
mysql_query($sqlAdd);
header("Location:add_connect_water.php?id=".@$_GET['id']."&msg=success");
exit;
}
}
else
{
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$name = $_POST["name"];
$info = $_POST["infor"];
IF($_FILES['file']['name']!='')
{
$tmp_name = $_FILES["file"]["tmp_name"];
$namefile = $_FILES["file"]["name"];
$ext = end(explode(".", $namefile));
$image_name=time().".".$ext;
$fileUpload = move_uploaded_file($tmp_name,"uploads/".$image_name);
}
$sqlAdd = mysql_query("insert into wtwo(name,infor,image) VALUES('$name','$info','$image_name')");
header("Location:index_water.php?msg=success");
exit;
}
}
ob_end_flush();
if(isset($_GET['msg']))
{
?>
<div style="color:red;padding-bottom:10px;" class="form-message" align="center"><b>Task completd successfully.</b></div>
<?php
}
?>
<!DOCTYPE html>
<html dir="ltr" lang="en-US"><head><!-- Created by Artisteer v4.0.0.58475 -->
<meta charset="utf-8">
<title>test</title>
<link rel="shortcut icon" href="http://sstatic.net/stackoverflow/img/favicon.ico">
<meta name="viewport" content="initial-scale = 1.0, maximum-scale = 1.0, user-scalable = no, width = device-width">
<link href='https://sites.google.com/site/test/favicon.png' rel='shortcut icon' type='image/x-icon'/>
<!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<link rel="stylesheet" href="css/style.css" media="screen">
<!--[if lte IE 7]><link rel="stylesheet" href="style.ie7.css" media="screen" /><![endif]-->
<link rel="stylesheet" href="css/style.responsive.css" media="all">
<script src="js/jquery.js"></script>
<script src="js/script.js"></script>
<script src="js/script.responsive.js"></script>
<script type="text/javascript" language="JavaScript">
jQuery(document).ready(function()
{
jQuery(".form-message").fadeOut(10000);
});
</script>
<link rel="shortcut icon" href="images/background/logo.PNG">
<style>.art-content .art-postcontent-0 .layout-item-0 { padding-right: 10px;padding-left: 10px; }
.ie7 .post .layout-cell {border:none !important; padding:0 !important; }
.ie6 .post .layout-cell {border:none !important; padding:0 !important; }
</style></head>
<body>
<div id="art-main">
<div id="art-header-bg" class="clearfix">
</div>
<div id="art-hmenu-bg" class="art-bar art-nav clearfix">
</div>
<div class="art-sheet clearfix">
<header class="art-header clearfix">
<div class="art-shapes">
<h1 class="art-headline" data-left="0.5%">
<a href="http://www.99demos.blogspot.com" target="_blank">ລັດວິສະຫະກິດ ນ້ຳປະປາ ນະຄອນຫຼວງ</a>
</h1>
</div>
<nav class="art-nav clearfix">
<div class="art-nav-inner">
<ul class="art-hmenu"><li><a href="index_water.php" class="active">Home</a></li></ul>
</div>
</nav>
</header>
<div class="art-layout-wrapper clearfix">
<div class="art-content-layout">
<div class="art-content-layout-row">
<div class="art-layout-cell art-content clearfix"><article class="art-post art-article">
<h2 class="art-postheader">ຍິນດີຕອ້ນຮັບ ທ່ານເຂົ້າສູ້ໜ້າຈັດການ ການບໍລິການ</h2>
<div class="art-postcontent art-postcontent-0 clearfix"><div class="art-content-layout">
<div class="art-content-layout-row">
<div class="art-layout-cell layout-item-0" style="width: 100%" >
<br>
<form method="post" name="login" id="login" enctype="multipart/form-data">
<table class="table" width="100%">
<tr>
<td width="10%">Name</td>
<td><input name="name" type="text" placeholder="Enter Name" required value="<?php echo @$row['name'];?>" maxlength=""></td>
</tr>
<tr>
<td width="10%">Image</td>
<td><input name="file" type="file" required ></td>
</tr>
<?php
if(isset($row['image']))
{
?>
<tr>
<td> </td>
<td><img src="uploads/<?php echo $row['image'];?> " height="50" width="50"></td>
</tr>
<?php
}
?>
<tr>
<td>infor</td>
<td><input name="info" type="text" placeholder="Enter Name" required value="<?php echo @$row['infor'];?>" maxlength=""></td>
</tr>
<tr>
<td> </td>
<td>
<input name="submit" value="Submit" type="submit" class="submit">
<input name="submit" value="Cancel" type="button" class="submit" onClick="window.location='index_water.php'"> </td>
</tr>
</table>
</form>
</div>
</div>
</div>
</div>
</article></div>
</div>
</div>
</div>
</div>
<footer class="art-footer clearfix">
<div class="art-footer-inner">
<p>Copyright © 2014 99Web Demos. All Rights Reserved.</p>
<p class="art-page-footer">
<span id="art-footnote-links"><a href="http://test,com" target="_blank">Tutorials</a> created with test.</span>
</p>
</div>
</footer>
</div>
</body></html>
Tag : PHP, HTML/CSS, JavaScript, Action Script, Ajax
|
|
|
|
|
|
Date :
2015-05-17 10:47:42 |
By :
doney |
View :
765 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$sqlAdd ="update wtwo set name='$name', info='$infor', image='$image_name' where id='$_GET[id]' ";
ลอง echo Query ออกมาดูครับ
|
|
|
|
|
Date :
2015-05-17 12:25:07 |
By :
bunchuai |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|