|
|
|
ขอสอบถามเกี่ยวกับการ Select Option ค่าที่ดึงมาจาก db หน่อยครับ |
|
|
|
|
|
|
|
Code (PHP)
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<?
include "dbconnect.php";
?>
<?
$nameSQL = "SELECT * FROM nc_workinglist WHERE Order_ID = '0000000013'";
$namequery = mysql_query($nameSQL);
if (mysql_num_rows($namequery) == 1)
{
$FetchArray = mysql_fetch_array($namequery);
mysql_fetch_array ($namequery);
//mysql_close();
$DBOrder_ID = $FetchArray['Order_ID'];
$DBCustomer_ID = $FetchArray['Customer_ID'];
$DBCustomer_NO = $FetchArray['Customer_NO'];
$DBOrder_Number = $FetchArray['Order_Number'];
$DBItem_Number = $FetchArray['Item_Number'];
$DBService_Type = $FetchArray['Service_Type'];
$DBSpeed = $FetchArray['Attribute1'];
$DBCarrier = $FetchArray['Attribute2'];
$DBCircuit_ID = $FetchArray['Attribute3'];
$DBRouter = $FetchArray['Attribute4'];
$DBInterface = $FetchArray['Attribute5'];
$DBLocal_IP = $FetchArray['Attribute6'];
$DBRemote_IP = $FetchArray['Attribute7'];
$DBDomain = $FetchArray['Attribute8'];
$DBBuilding = $FetchArray['Attribute9'];
$DBSite = $FetchArray['Attribute10'];
$DBRoute_Object = $FetchArray['Attribute11'];
$DBInter_Speed = $FetchArray['Attribute12'];
$DBUpdate_By = $FetchArray['Update_By'];
$DBLast_Update = $FetchArray['Last_Update'];
$DBService_UP = $FetchArray['Service_UP'];
$DBExpect_Date = $FetchArray['Expect_Date'];
$DBEnd_Date = $FetchArray['End_Date'];
}
preg_match("/[[:digit:]]+\.?[[:digit:]]*/", $DBSpeed , $matchspeed );
$matchspeed[0];
preg_match("/[[:digit:]]+\.?[[:digit:]]*/", $DBInter_Speed , $matchspeedinter );
$matchspeedinter[0];
$findme_1 = "K";
$findme_2 = "k";
$findme_3 = "M";
$findme_4 = "m";
$result_1 = strpos($DBSpeed, $findme_1);
$result_2 = strpos($DBSpeed, $findme_2);
$result_3 = strpos($DBSpeed, $findme_3);
$result_4 = strpos($DBSpeed, $findme_4);
$result_5 = strpos($DBInter_Speed, $findme_1);
$result_6 = strpos($DBInter_Speed, $findme_2);
$result_7 = strpos($DBInter_Speed, $findme_3);
$result_8 = strpos($DBInter_Speed, $findme_4);
if ($result_1 != '')
{
$resultspeed = "Kbps";
}
else if ($result_2 != '')
{
$resultspeed = "kbps";
}
else if ($result_3 != '')
{
$resultspeed = "Mbps";
}
else if ($result_4 != '')
{
$resultspeed = "mbps";
}
$resultspeed = $matchspeed[0]." ".$resultspeed."<br>";
if ($result_5 != '')
{
$resultspeedinter = "Kbps";
}
else if ($result_6 != '')
{
$resultspeedinter = "kbps";
}
else if ($result_7 != '')
{
$resultspeedinter = "Mbps";
}
else if ($result_8 != '')
{
$resultspeedinter = "mbps";
}
$resultspeedinter = $matchspeedinter[0]." ".$resultspeedinter;
?>
<select name = "namespeed">
<option value=""><-- Please Select Item --></option>
<?
$strSQL = "SELECT * FROM namespeed where namespeed = '$resultspeed' ORDER BY Value ASC";
$objQuery = mysql_query($strSQL);
while($objResult = mysql_fetch_array($objQuery))
{
if($resultspeed == $objResult["Value"])
{
$sel = "selected";
}
else
{
$sel = "Please Select";
}
?>
<option value = "<?=$objResult["Value"];?>" <?=$sel;?> > <?=$objResult["Value"]?></option>
<?
}
?>
</select>
จาก code อยากทราบว่าทำไมมันไม่ไป query ข้อมูลใน db มาแสดงครับ ทั้งๆที่ code ก็ลองไปดึงในฐานช้อมูลตรงๆมันก็แสดงผลปกติ
Tag : PHP, MySQL, HTML/CSS, CakePHP
|
|
|
|
|
|
Date :
2013-05-13 09:28:45 |
By :
Anonymous |
View :
782 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
while($objResult = mysql_fetch_array($objQuery))
{
if($resultspeed == $objResult["Value"])
{
?>
<option value = "<?=$objResult["Value"];?>" selected="selected" > <?=$objResult["Value"]?></option>
<?
}
else
{
?>
<option value = "<?=$objResult["Value"];?>"> <?=$objResult["Value"]?></option>
<?
}
}
|
ประวัติการแก้ไข 2013-05-13 09:47:58 2013-05-13 09:53:17
|
|
|
|
Date :
2013-05-13 09:37:16 |
By :
bankza009 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|