|
|
|
จะส่งข้อมูลทั้งหมดอย่างไร กรณีTable เดียวกันแต่อัพเดตให้ตรงกับ parameter |
|
|
|
|
|
|
|
จากภาพ สงสัยเกี่ยวกับการสร้างโค้ดเพื่อให้มันสามารถอัพเดตในตารางเดียวกันให้ได้ทั้งหมด คือตอนนี้ติดอยู่ที่ข้อมูลส่งได้แค่ค่าสุดท้ายค่าเดียว กรุรูท่านไหนตอบได้ช่วยตอบทีนะคะ ขอบคุณค่ะ
Code (PHP)
<?php require_once('Connections/PORTAL_ADMIN.php');
$sid=$_GET['sid'];
$master=$_GET['master2'];
?>
<!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>Add Netflow</title>
<style type="text/css">
<!--
.style1 {
color: #FF0000;
font-weight: bold;
}
.style2 {
color: #009900;
font-weight: bold;
}
-->
</style>
</head>
<body>
<span class="style2">ZONE NETFLOW</span>
<ul>
<li>Show NETFLOW
<?
// mysql_query("SET NAMES UTF8");
$sqlnet="select * from cs_service_parameter s where s.cs_account_id='$master' and s.cs_service_name_id='$sid' ";
$senet=mysql_db_query("portal_ntt2",$sqlnet);
$runet=mysql_fetch_array($senet);
$paranet=$runet['number_of_site'];
$cs_id=$runet['cs_account_id'];
$name_id=$runet['cs_service_name_id'];
//$mrtg=$ru2['cs_site_id'];
?>
<ul>
<li>Number of site: <? echo $runet['number_of_site'];?><br />
Site: <br />
<?
$b=1;
while($b<=$paranet){
$showparanet ="parameter_".$b;
echo "$b.<a href='detailmember2.php?router_id=$runet[$showparanet]&master=$runet[cs_account_id]'>$runet[$showparanet]</a></br>";
//&total=$runet[number_of_site]
//$testnet= $runet[$showparanet];
$value2= $runet[$showparanet];
//
$b++;
}
?>
</li>
</ul>
</li>
</ul>
<form action="add_netflow.php?master2=<? echo $runet['cs_account_id'];?>&sid=<? echo $runet['cs_service_name_id'];?>" method="post" name="form1">
Add number site
<input type="text" name="addsite" value="<? echo $addsite;?>" />
<input type="submit" name="Submit" value="Addsite" />
</form>
<?
global $addsite;
$addsite =$_POST['addsite'];
global $total;
$total = $addsite+$paranet;
echo "Total site:".$total."<br>";
//}
?>
</p>
<table width="655" border="1">
<tbody>
<tr>
<th width="79" bgcolor="#99FFCC" scope="col">No.</th>
<th width="227" bgcolor="#99FFCC" scope="col">Name_Site</th>
<th width="95" bgcolor="#99FFCC" scope="col">Router_id</th>
<th width="112" bgcolor="#99FFCC" scope="col">link_speed</th>
<th width="108" bgcolor="#99FFCC" scope="col">data_source</th>
</tr>
<?
$a=$addsite;
//$row =$total-$paranet;
if($a==0 || $a==""){
echo "Please, insert number site";
}
else{
echo "<form action='add_netflow2.php?master2=$runet[cs_account_id]&sid=$runet[cs_service_name_id]' method='post' name='form2'>";
for($b>$paranet;$b<=$total;++$b){
echo "<tr> $b
<input type='hidden' name='total5' value='$total'/>
<input type='hidden' name='total2' value='$b'/>
<th bgcolor='#FFFFFF' scope='col'><input type='text' name='para_k' value='parameter_$b' disabled='disabled'/></th>
<th bgcolor='#FFFFFF' scope='col'><input type='text' name='name_site' value='' size='30'/></th>
<th bgcolor='#FFFFFF' scope='col'><input type='text' name='router_id' value='' size='30'/></th>
<th bgcolor='#FFFFFF' scope='col'><input type='text' name='link_speed' value='Mbps' size='10'/></th>
<th bgcolor='#FFFFFF' scope='col'><input type='text' name='data_source' value='' size='20'/></th>
</tr>";
//$a++;
}
echo "<input type='submit' name='Submit' value='Insert Data' />";
echo "</form>";
}
?>
ส่วนหน้าอัพโหลดเป็นดังนี้
Code (PHP)
<?php require_once('Connections/PORTAL_ADMIN.php');
$sid=$_GET['sid'];
$master2=$_GET['master2'];
$sql2="select * from cs_service_parameter s where s.cs_account_id='$master2' and s.cs_service_name_id='$sid' ";
$se=mysql_db_query("portal_ntt2",$sql2);
$ru2=mysql_fetch_array($se);
$para=$ru2['number_of_site'];
//update_service_parameter
$d4=$_POST['total2'];
$parameter = $_POST['para_k'];
$total5=$_POST['total5'];
$name_site = $_POST['name_site'];
$router_id = $_POST['router_id'];
$link_speed = $_POST['link_speed'];
$data_source=$_POST['data_source'];
$checktime=date("Y-m-d");
?>
<?
$aa2=1;
////global $value;
while($aa2<=$para){
$showpara ="parameter_".$aa2;
$aa2++;
}
?>
<?
$aa2==$d4;
$bb=$name_site;
//for ($bb>$para;$bb==$name_site;++$bb){
echo $bb;
//}
$sql="UPDATE cs_service_parameter SET number_of_site='$total5', parameter_$aa2='$bb' WHERE cs_account_id='$master2' and cs_service_name_id='$sid'";
mysql_db_query("portal_ntt2",$sql);
$result="insert into cs_parameter_netflow_site_router(cs_site_id,number_of_router,router_1) values ('$bb','1','$router_id')";
$result2= mysql_db_query("portal_ntt2",$result);
$detailnet="insert into cs_parameter_netflow_router_information(router_id,link_speed,data_source,last_update) values ('$router_id','$link_speed','$data_source','$checktime')";
$nettail= mysql_db_query("portal_ntt2",$detailnet);
if($result2 and $nettail){
echo "<h3><center><img src='images/action_check.png' border='0'/><font color='#9B30FF'>Update and Record Data Successful</font></center></h3>";
echo "<meta http-equiv='refresh' content='2;URL= mainadmin.php'/>";
}
else{
echo "Fail to update Data!!!";
//exit();
}
Tag : PHP
|
|
|
|
|
|
Date :
2012-01-13 17:19:56 |
By :
namisan |
View :
946 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- - !!! ขอบคุณค่ะ แต่คงต้องแก้อีกเยอะแน่เลย
|
|
|
|
|
Date :
2012-01-13 17:40:42 |
By :
namisan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|