 |
|
|
 |
 |
|
คือ เวลาเรา add แล้ว มันจะโชว์ ข้อมูลที่ add ไปก่อนหน้านี้ เป็นช่อง ช่อง ขวาสุด ก้อจะมีให้เลือก edit กะ delete ครับ เเล้วจะช่องดูรูปภาพที่เรา add ไปอ่ะครับ
|
 |
 |
 |
 |
Date :
2010-05-14 12:00:56 |
By :
PISTOLA |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
โค๊ด add edit detele
<html>
<head>
<title>Add</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("tot");
if($_POST["hdnCmd"] == "Add" || copy($_FILES["filUpload"]["tmp_name"],"myfile/".$_FILES["filUpload"]["name"]) )
{
$strSQL = "INSERT INTO project ";
$strSQL .="(number,type,customer,host) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtAddnumber"]."','".$_POST["txtAddtype"]."' ";
$strSQL .=",'".$_POST["txtAddcustomer"]."' ";
$strSQL .=",'".$_POST["txtAddhost"]."') ";
$strSQL .="(FilesName) VALUES ('".$_FILES["filUpload"]["name"]."')";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Save [".mysql_error()."]";
}
}
if($_POST["hdnCmd"] == "Update")
{
$strSQL = "UPDATE project SET ";
$strSQL .="number = '".$_POST["txtEditnumber"]."' ";
$strSQL .=",type = '".$_POST["txtEdittype"]."' ";
$strSQL .=",customer = '".$_POST["txtEditcustomer"]."' ";
$strSQL .=",host = '".$_POST["txtEdithost"]."' ";
$strSQL .="WHERE number = '".$_POST["hdnEditnumber"]."' ";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Update [".mysql_error()."]";
}
}
if($_GET["Action"] == "Del")
{
$strSQL = "DELETE FROM project ";
$strSQL .="WHERE number = '".$_GET["CusID"]."' ";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Delete [".mysql_error()."]";
}
}
$strSQL = "SELECT * FROM project";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<form name="frmMain" method="post" action="<?=$_SERVER["PHP_SELF"];?>">
<input type="hidden" name="hdnCmd" value="">
<table width="100" cellpadding=0 cellspacing=0 border="1">
<tr>
<th width="100"> <div align="center">หมายเลขวงจร</div></th>
<th width="100"> <div align="center">ประเภทวงจรเช่า </div></th>
<th width="10"> <div align="center">ลูกค้า </div></th>
<th width="10"> <div align="center">host </div></th>
<th width="50"> <div align="center">Edit </div></th>
<th width="50"> <div align="center">Delete </div></th>
<th width="50"> <div align="center">รูปภาพ </div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<?
if($objResult["number"] == $_GET["CusID"] and $_GET["Action"] == "Edit")
{
?>
<tr>
<td><div align="center">
<input type="text" name="txtEditnumber" size="5" value="<?=$objResult["number"];?>">
<input type="hidden" name="hdnEditnumber" size="10" value="<?=$objResult["number"];?>">
</div></td>
<td><input type="text" name="txtEdittype" size="30" value="<?=$objResult["type"];?>"></td>
<td><input type="text" name="txtEditcustomer" size="30" value="<?=$objResult["customer"];?>"></td>
<td><div align="center"><input type="text" name="txtEdithost" size="10" value="<?=$objResult["host"];?>"></div></td>
<td colspan="2" align="right"><div align="center">
<input name="btnAdd" type="button" id="btnUpdate" value="Update" OnClick="frmMain.hdnCmd.value='Update';frmMain.submit();">
<input name="btnAdd" type="button" id="btnCancel" value="Cancel" OnClick="window.location='<?=$_SERVER["PHP_SELF"];?>';">
</div></td>
</tr>
<?
}
else
{
?>
<tr>
<td><div align="center"><?=$objResult["number"];?></div></td>
<td><?=$objResult["type"];?></td>
<td><?=$objResult["customer"];?></td>
<td><div align="center"><?=$objResult["host"];?></div></td>
<td align="center"><a href="<?=$_SERVER["PHP_SELF"];?>?Action=Edit&CusID=<?=$objResult["number"];?>">Edit</a></td>
<td align="center"><a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='<?=$_SERVER["PHP_SELF"];?>?Action=Del&CusID=<?=$objResult["number"];?>';}">Delete</a></td>
</tr>
<?
}
?>
<?
}
?>
<tr>
<td><div align="center"><input type="text" name="txtAddnumber" size="30"></div></td>
<td><input type="text" name="txtAddtype" size="20"></td>
<td><input type="text" name="txtAddcustomer" size="20"></td>
<td><div align="center"><input type="text" name="txtAddhost" size="2"></div></td>
<td colspan="2" align="right"><div align="center">
<form name="form1" method="post" enctype="multipart/form-data">
<input type="file" name="filUpload"><br>
</form>
<input name="btnAdd" type="button" id="btnAdd" value="Add" OnClick="frmMain.hdnCmd.value='Add';frmMain.submit();">
</div></td>
</tr>
</table >
</form>
<?
mysql_close($objConnect);
?>
<a href="logout.php">ออกจากระบบ</a><p>
</body>
</html>
|
 |
 |
 |
 |
Date :
2010-05-14 12:01:41 |
By :
PISTOLA |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
โค๊ดอัพโหลดรูป
Code (PHP)
<html>
<head>
<title>Upload</title>
</head>
<body>
<form name="form1" method="post" action="PageUploadToMySQL2.php" enctype="multipart/form-data">
<input type="file" name="filUpload"><br>
<input name="btnSubmit" type="submit" value="Submit">
</form>
</body>
</html>
Code (PHP)
<html>
<head>
<title>Upload</title>
</head>
<body>
<?
if(copy($_FILES["filUpload"]["tmp_name"],"myfile/".$_FILES["filUpload"]["name"]))
{
echo "Copy/Upload Complete<br>";
//*** Insert Record ***//
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("tot");
$strSQL = "INSERT INTO project ";
$strSQL .="(FilesName) VALUES ('".$_FILES["filUpload"]["name"]."')";
$objQuery = mysql_query($strSQL);
}
?>
<a href="PageUploadToMySQL3.php">View files</a>
</body>
</html>
Code (PHP)
<html>
<head>
<title>Upload</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("tot");
$strSQL = "SELECT FilesName FROM project";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="200" border="1">
<tr>
<th width="150"> <div align="center">Files Name </div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><center><a href="myfile/<?=$objResult["FilesName"];?>"><?=$objResult["FilesName"];?></a></center></td>
</tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?>
</body>
</html>
|
 |
 |
 |
 |
Date :
2010-05-14 12:03:17 |
By :
PISTOLA |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่รู้มารวมกันทำไงอ่ะครับ คืออยากให้อยู่หน้าเดียวกัน
|
 |
 |
 |
 |
Date :
2010-05-14 12:03:46 |
By :
PISTOLA |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|