|
|
|
อยากย้ายข้อมูลตาราง จาก ตาราง 1 ไปยังตาราง 2 ด้วยcheckbox แล้วกด submit อะครับ |
|
|
|
|
|
|
|
ผมเพิ่งหัดเขียนน่ะครับ แล้วพยายามหาทางมา 2 วันแล้วยังไม่ค่อยเข้าใจ
อยากให้พี่ๆช่วยผมหน่อย พอจะมีโค้ดไหมคับ
อันนี้เป็นโคดจากหน้าฟอมแรกอะครับ แล้วผมอยากให้ข้อมูลที่โชในฟอมนี้ ย้ายไปอีกหน้านึงน่ะครับ
Code (PHP)
<?php require_once('../../Connections/Myconnect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_Myconnect, $Myconnect);
mysql_query("SET NAMES UTF8");
$query_Recordset1 = "SELECT * FROM form_use_car";
$Recordset1 = mysql_query($query_Recordset1, $Myconnect) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!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=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body {
background-attachment:fixed;
background-color: #E6E6E6;
color: #CCC;
}
</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 >
<table width="1503" height="678" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th width="1503" height="678" colspan="2" scope="row"><table width="1503" height="749" border="0" align="center" cellpadding="0" cellspacing="0">
<tr align="center">
<th height="400" colspan="8" align="center" valign="bottom" scope="col"><img src="../Photos/Admin_head .png" width="1500" height="400" /></th>
</tr>
<tr align="center" valign="top">
<th width="150" height="50" bgcolor="#4F2F1F" scope="row"><a href="Report_Admin.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image11','','../Photos/bt_Ad_report(s).png',1)"><img src="../Photos/bt_Ad_report.png" name="Image11" width="150" height="50" border="0" id="Image11" /></a><br /> </th>
<th width="301" bgcolor="#705347" scope="row"><a href="index_Admin.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image3','','../Photos/bt_Ad_home(s).png',1)"><img src="../Photos/bt_Ad_home.png" name="Image3" width="300" height="50" border="0" id="Image3" /></a></th>
<th width="301" bgcolor="#705347" scope="row"><a href="request_Admin.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image4','','../Photos/bt_Ad_use(s).png',1)"><img src="../Photos/bt_Ad_use.png" name="Image4" width="300" height="50" border="0" id="Image4" /></a></th>
<th width="301" bgcolor="#705347" scope="row"><a href="Statuscar1_Admin.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image5','','../Photos/bt_Ad_statuscar(s).png',1)"><img src="../Photos/bt_Ad_statuscar.png" name="Image5" width="300" height="50" border="0" id="Image5" /></a></th>
<th width="301" bgcolor="#705347" scope="row"><a href="Showemp_Admin.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image6','','../Photos/bt_Ad_dataCus(s).png',1)"><img src="../Photos/bt_Ad_dataCus .png" name="Image6" width="300" height="50" border="0" id="Image6" /></a></th>
<th colspan="3" align="left" bgcolor="#4F2F1F" scope="row"><a href="Return_Admin.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image10','','../Photos/bt_Ad_return(s).png',1)"> <img src="../Photos/bt_Ad_return.png" name="Image10" width="150" height="50" border="0" id="Image10" /></a></th>
</tr>
<tr align="center" valign="top">
<th height="51" colspan="8" align="center" bgcolor="#4F2F1F" scope="row"><p> </p>
<p>คำขอใช้รถจาก usr ทุกคน</p>
<p> </p>
<form id="form1" name="form1" method="post" action="add.php">
<table border="1">
<tr>
<td> </td>
<td>ID_Order</td>
<td>ID</td>
<td>Name</td>
<td>SName</td>
<td>Department</td>
<td>Part</td>
<td>Email</td>
<td>Phone</td>
<td>Type_car</td>
<td>Passenger</td>
<td>Location</td>
<td>Date_use_car</td>
<td>Dateend_use_car</td>
<td>Note_use_for</td>
<td>option</td>
</tr>
<?php do { ?>
<tr>
<td><input type="checkbox" name="Check_1" id="Check_1" />
<label for="Check_1"></label></td>
<td><?php echo $row_Recordset1['ID_Order']; ?></td>
<td><?php echo $row_Recordset1['ID']; ?></td>
<td><?php echo $row_Recordset1['Name']; ?></td>
<td><?php echo $row_Recordset1['SName']; ?></td>
<td><?php echo $row_Recordset1['Department']; ?></td>
<td><?php echo $row_Recordset1['Part']; ?></td>
<td><?php echo $row_Recordset1['Email']; ?></td>
<td><?php echo $row_Recordset1['Phone']; ?></td>
<td><?php echo $row_Recordset1['Type_car']; ?></td>
<td><?php echo $row_Recordset1['Passenger']; ?></td>
<td><?php echo $row_Recordset1['Location']; ?></td>
<td><?php echo $row_Recordset1['Date_use_car']; ?></td>
<td><?php echo $row_Recordset1['Dateend_use_car']; ?></td>
<td><?php echo $row_Recordset1['Note_use_for']; ?></td>
<td> </td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
<p> </p>
<p>
<input type="submit" name="btn_go" id="btn_go" value="Submit" />
</p>
</form>
<p> </p>
<p> </p></th>
</tr>
<tr>
<th height="20" colspan="8" bgcolor="#705347" scope="row"><img src="../Photos/Admin_lower.png" width="1500" height="200" /></th>
</tr>
<tr>
<th height="48" colspan="8" valign="top" scope="row"> </th>
</tr>
</table></th>
</tr>
</table>
<map name="Map" id="Map">
<area shape="circle" coords="514,369,28" href="https://login.live.com/" target="_top" />
<area shape="rect" coords="422,9,455,20" href="../index.html" />
<area shape="circle" coords="443,368,27" href="https://www.facebook.com" />
<area shape="circle" coords="586,367,28" href="https://www.youtube.com/" />
<area shape="rect" coords="484,11,528,19" href="#" />
<area shape="rect" coords="510,395,512,414" href="#" />
</map>
<map name="Map2" id="Map2">
<area shape="rect" coords="485,60,745,81" href="https://www.facebook.com/ikkyu.kladthrong" />
</map>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
Tag : MySQL
|
|
|
|
|
|
Date :
2015-05-15 21:52:58 |
By :
ikkyu |
View :
1189 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (form.php)
<html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
</head>
<body>
<script language="JavaScript">
function onSave()
{
if(confirm('Do you want to save ?')==true)
{
return true;
}
else
{
return false;
}
}
</script>
<form name="frmMain" action="save.php" method="post" OnSubmit="return onSave();">
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">CustomerID </div></th>
<th width="98"> <div align="center">Name </div></th>
<th width="198"> <div align="center">Email </div></th>
<th width="97"> <div align="center">CountryCode </div></th>
<th width="59"> <div align="center">Budget </div></th>
<th width="71"> <div align="center">Used </div></th>
<th width="30"> <div align="center">Select </div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center"><?=$objResult["CustomerID"];?></div></td>
<td><?=$objResult["Name"];?></td>
<td><?=$objResult["Email"];?></td>
<td><div align="center"><?=$objResult["CountryCode"];?></div></td>
<td align="right"><?=$objResult["Budget"];?></td>
<td align="right"><?=$objResult["Used"];?></td>
<td align="center"><input type="checkbox" name="chkEmail[]" value="<?=$objResult["Email"];?>"></td>
</tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?>
<input type="submit" name="btnSave" value="Save">
</form>
</body>
</html>
Code (save.php)
<html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
for($i=0;$i<count($_POST["chkEmail"]);$i++)
{
if($_POST["chkEmail"][$i] != "")
{
$strSQL = "INSERT INTO table_name (Mail) VALUES ('".$_POST["chkEmail"][$i]."')";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
}
}
echo "Record Insert.";
mysql_close($objConnect);
?>
</body>
</html>
Go to : PHP Multiple Checkbox
|
|
|
|
|
Date :
2015-05-16 07:31:34 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|