|
 |
|
php forceh เรื่องการวนลูป array คือในเครื่องอ่ะทำงานแต่พอขึ้น server มันไม่ยอมวนลูปให้ค่ะ |
|
 |
|
|
 |
 |
|
นี้คือหน้าโค้ดทั้งหมดค่ะ
Code (PHP)
@session_start();
$id=$sessiondata["id"];
session_register("sessiondata");
include("config.php");
$id= $_GET['id'];
//include("head.php");
?>
<?
$IPtype_id=$_POST['IPtype_id'];
$IP_id=$_POST['IP_id'];
$IP_name = $_POST['IP_name'];
$D_rec_req= $_POST['D_rec_req'];
$D_app = $_POST['D_app'];
$app_no=$_POST['app_no'];
$inventor=$_POST['inventor'];
$holder[]=$_POST['hol_id'];
$sta_id=$_POST['sta_id'];
$note=$_POST['note'];
mysql_query($sql);
if(copy($_FILES["f_ip"]["tmp_name"],"document/".$_FILES["f_ip"]["name"]))
{
if(copy($_FILES["f_app"]["tmp_name"],"document/".$_FILES["f_app"]["name"]))
{
list($d,$m,$y)=explode("/",$D_rec_req);
$D_rec_req=($y-543)."-".$m."-".$d;
list($d,$m,$y)=explode("/",$D_app);
$D_app=($y-543)."-".$m."-".$d;
$date=date('dd/mm/yy');
//include("config.php");
//echo $holder[0];
//$aaa=("select * from ip where hol_id");
//$arr=array($aaa);
//$arr = array($holder);
foreach ($holder as $key => $value){
if($value!=0){
echo $sql="INSERT INTO ip VALUES (id,'$IPtype_id','$IP_id','$IP_name','$D_rec_req','$D_app','$app_no','$inventor','$value','$sta_id','$note','".$_FILES["f_ip"]
["name"]."','".$_FILES["f_app"]["name"]."')" ;
//print $key = $var1;
mysql_query($sql);
}
}
$sql2="update iptype set IP_default='".$IP_id."' where IPtype_id='".$IPtype_id."' ";
mysql_query($sql2);
$complete = "true" ;
//echo $sql;
// close foreach
?>
<!--<META HTTP-EQUIV="Refresh" CONTENT="0;URL=search_ip.php">-->
<? }?>
<? }?>
|
ประวัติการแก้ไข 2012-07-27 16:13:12
 |
 |
 |
 |
Date :
2012-07-27 16:09:43 |
By :
romrung1 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$holder[]=$_POST['hol_id']; ค่าที่ได้มามันเป็น อะเรย์มันก็ต้องมีการแทนค่าเพื่อเรียกใช้อะเรย์
เช่น $t = $holder[0] ; จากนั้นเราจึงนำค่า $t ไปใช้งาน
อันนี้ผมถามเพิ่มนะครับ เพราะผมไม่เคยใช้ foreach เลยจะถามว่า
foreach มีการแทนที่ค่าของอะเรย์ด้วยหรือเปล่าครับ
ถ้าท่านใดมาอ่านช่วยแนะนำด้วยครับ
|
 |
 |
 |
 |
Date :
2012-07-28 16:13:49 |
By :
apisitp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ประกาศ
$holder = array();
แล้วกำหนดค่า
$holder=$_POST['hol_id'];
ลองดูครับไม่รู้ถูกป่าว
|
 |
 |
 |
 |
Date :
2012-07-28 21:55:39 |
By :
Krungsri |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|