|
|
|
ช่วยที่ครับ ดึงข้อมูลจาก 2 ที่ แล้วเอามาแสดงรวมกันในตารางเดียว |
|
|
|
|
|
|
|
คือผมจะดึงข้อมูลจาก2ที่แล้วเอามารวมกันในตารางเดียวควรทำไงครับทำแล้วค่าในตารางมันมั่วไปหมดเลย ข้อมูลที่ 1 มาจากไฟล์ .csv ข้อมูลที่ 2จากฐานข้อมูลครับ
ที่วงสีแดงมาจากฐานข้อมูล ผมจะทำให้มันต่อท้ายที่วงสีเหลืองยังไงครับ
Code (PHP)
<html>
<head>
<title>Read CSV & MSSQL </title>
</head>
<body>
<br>
<form action="phpCSVMySQLUpload.php" method="post" enctype="multipart/form-data" name="form1">
<input name="fileCSV" type="file" id="fileCSV">
<?php
$objCSV = fopen("scan.csv", "r"); //scan.csv
?>
<?php
$objConnect = mysql_connect("localhost","root","123456") or die("Error Connect to Database");
$objDB = mysql_select_db("mydata");
$strSQL = "SELECT * FROM member";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">Uid </div></th>
<th width="98"> <div align="center">Qty </div></th>
<th width="198"> <div align="center">Note </div></th>
<th width="97"> <div align="center">Time/Date </div></th>
<th width="91"> <div align="center">PARTNUMBER </div></th>
<th width="98"> <div align="center">PARTNUMBER_PO </div></th>
<th width="198"> <div align="center">SERIAL_NO </div></th>
<th width="97"> <div align="center">RESERVED </div></th>
<th width="59"> <div align="center">DESCRIPTN </div></th>
<th width="51"> <div align="center">WHCODE </div></th>
</tr>
<?php
while (($objArr = fgetcsv($objCSV, 1000, ",")) !== FALSE) {
?>
<tr>
<td><div align="center"><?php echo $objArr[0];?></div></td>
<td><?php echo $objArr[1];?></td>
<td><?php echo $objArr[2];?></td>
<td><div align="center"><?php echo $objArr[3];?></div></td>
</tr>
<?php
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center"><?php echo $objResult["MemberID"];?></div></td>
<td><?php echo $objResult["Username"];?></td>
<td><?php echo $objResult["Password"];?></td>
<td><div align="center"><?php echo $objResult["Name"];?></div></td>
<td align="right"><?php echo $objResult["Tel"];?></td>
<td align="right"><?php echo $objResult["Email"];?></td>
</tr>
</tr>
<?php
}
?>
<?php
}
?>
</table>
</table>
</body>
</html
Tag : PHP, Ms SQL Server 2012, Excel (Excel.Application), Web (ASP.NET), Web Service
|
|
|
|
|
|
Date :
2015-07-07 09:54:55 |
By :
oreo1109 |
View :
2815 |
Reply :
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เก็บข้อมูลจากเดต้าเบสลงตัวแปรอาร์เรย์ก่อนค่ะ แล้วค่อยนำมาแสดงพร้อมๆกับข้อมูลจากไฟล์ csv
Code (PHP)
<html>
<head>
<title>Read CSV & MSSQL </title>
</head>
<body>
<br>
<form action="phpCSVMySQLUpload.php" method="post" enctype="multipart/form-data" name="form1">
<input name="fileCSV" type="file" id="fileCSV">
<?php
$objCSV = fopen("scan.csv", "r"); //scan.csv
?>
<?php
$objConnect = mysql_connect("localhost","root","123456") or die("Error Connect to Database");
$objDB = mysql_select_db("mydata");
$strSQL = "SELECT * FROM member";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($arrayData[] = mysql_fetch_array($objQuery)){ }
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">Uid </div></th>
<th width="98"> <div align="center">Qty </div></th>
<th width="198"> <div align="center">Note </div></th>
<th width="97"> <div align="center">Time/Date </div></th>
<th width="91"> <div align="center">PARTNUMBER </div></th>
<th width="98"> <div align="center">PARTNUMBER_PO </div></th>
<th width="198"> <div align="center">SERIAL_NO </div></th>
<th width="97"> <div align="center">RESERVED </div></th>
<th width="59"> <div align="center">DESCRIPTN </div></th>
<th width="51"> <div align="center">WHCODE </div></th>
</tr>
<?php
$index=0;
while (($objArr = fgetcsv($objCSV, 1000, ",")) !== FALSE) {
?>
<tr>
<td><div align="center"><?php echo $objArr[0];?></div></td>
<td><?php echo $objArr[1];?></td>
<td><?php echo $objArr[2];?></td>
<td><div align="center"><?php echo $objArr[3];?></div></td>
<td><div align="center"><?php echo $arrayData[$index]["MemberID"];?></div></td>
<td><?php echo $arrayData[$index]["Username"];?></td>
<td><?php echo $arrayData[$index]["Password"];?></td>
<td><div align="center"><?php echo $arrayData[$index]["Name"];?></div></td>
<td align="right"><?php echo $arrayData[$index]["Tel"];?></td>
<td align="right"><?php echo $arrayData[$index]["Email"];?></td>
</tr>
<?php
++$index;
}
?>
</table>
</body>
</html
ไม่ทราบว่าตรงกับที่ต้องการหรือป่าวน่ะ
|
|
|
|
|
Date :
2015-07-07 10:52:39 |
By :
survivor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แบบนี้ค่ะ วนลูปข้อมูลในไฟล์ csv แล้วนำ uid ที่อยู่ในอาร์เรย์ลำดับที่ 0 ไปคิวรี่ในเดต้าเบส
Code (PHP)
<html>
<head>
<title>Read CSV & MSSQL </title>
</head>
<body>
<br>
<form action="phpCSVMySQLUpload.php" method="post" enctype="multipart/form-data" name="form1">
<input name="fileCSV" type="file" id="fileCSV">
<?php
$objCSV = fopen("scan.csv", "r"); //scan.csv
?>
<?php
$objConnect = mysql_connect("localhost","root","123456") or die("Error Connect to Database");
$objDB = mysql_select_db("mydata");
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">Uid </div></th>
<th width="98"> <div align="center">Qty </div></th>
<th width="198"> <div align="center">Note </div></th>
<th width="97"> <div align="center">Time/Date </div></th>
<th width="91"> <div align="center">PARTNUMBER </div></th>
<th width="98"> <div align="center">PARTNUMBER_PO </div></th>
<th width="198"> <div align="center">SERIAL_NO </div></th>
<th width="97"> <div align="center">RESERVED </div></th>
<th width="59"> <div align="center">DESCRIPTN </div></th>
<th width="51"> <div align="center">WHCODE </div></th>
</tr>
<?php
$index=0;
while (($objArr = fgetcsv($objCSV, 1000, ",")) !== FALSE) {
?>
<tr>
<td><div align="center"><?php echo $objArr[0];?></div></td>
<td><?php echo $objArr[1];?></td>
<td><?php echo $objArr[2];?></td>
<td><div align="center"><?php echo $objArr[3];?></div></td>
<?php
$strSQL = "SELECT * FROM view_stocklist where uid='{$objArr[0]}'";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$arrayData = mysql_fetch_array($objQuery);
?>
<td><div align="center"><?php echo $arrayData["MemberID"];?></div></td>
<td><?php echo $arrayData["Username"];?></td>
<td><?php echo $arrayData["Password"];?></td>
<td><div align="center"><?php echo $arrayData["Name"];?></div></td>
<td align="right"><?php echo $arrayData["Tel"];?></td>
<td align="right"><?php echo $arrayData["Email"];?></td>
</tr>
<?php
}
?>
</table>
</body>
</html
|
|
|
|
|
Date :
2015-07-07 12:39:35 |
By :
survivor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2015-07-07 17:08:20 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
สอบถามครับ
ผมต้องการให้ข้อมูลที่เลือก form select ออกมาต่อท้ายกัน ต้องเขียน code ในรูปแบบไหนครับ
อยากเอาข้อมูลในช่องสีแดงมาต่อท้ายสีเหลืองครับ
เพื่อนจะนำ ข้อมูลมาแสดงเป็นกราฟ ซึ่งข้อมูลอยุ่ไม่ได้อยุ่ในไฟล์เดียวกันครับ
Code (PHP)
[php][/<?php
$datafile=file($_POST["top"]);//??????????????
for($i=0; $i<26; $i++){ ${'num'.$i}=array();} //???????????? array
$i = 0;
foreach ($datafile as $i => $line){//??????????????
list($num1[$i],$num2[$i],$num3[$i],$num4[$i],$num5[$i],$num6[$i],$num7[$i],$num8[$i],$num9[$i],$num10[$i],$num11[$i],$num12[$i],$num13[$i],$num14[$i],$num15[$i],$num16[$i],$num17[$i],$num18[$i],$num19[$i],$num20[$i],$num21[$i],$num22[$i],$num23[$i],$num24[$i],$num25[$i]) = explode(',', substr($line,0)); //??????????? array
$num1[$i] = intval(substr($num1[$i],0,-2));
$num18[$i] = intval($num18[$i]); //???? colum ??????????????
$num19[$i] = intval($num19[$i]);
$num20[$i] = intval($num20[$i]);
$num21[$i] = intval($num21[$i]);
$num22[$i] = intval($num22[$i]);
$target1[$i] = 10;
$target2[$i] = 20;
$target3[$i] = 30;
$i++;
}
$T= substr($_POST["top"],13);
$R= str_replace("H0"," MC#",$T);
$P= str_replace("E."," - ",$R);
echo ("$P");
unset($file_array) ; echo '<pre>'; //?????????
//echo 'num0 = '; echo implode(',', $num1); echo '<br>';
echo 'Loadcell-1 = '; echo implode(',', $num19); echo '<br>';
echo 'Loadcell-2 = '; echo implode(',', $num20); echo '<br>';
echo 'Loadcell-3 = '; echo implode(',', $num21); echo '<br>';
echo 'Loadcell-4 = '; echo implode(',', $num22); echo '</pre>';
?>
<?php
$datafile=file($_POST["top1"]);//??????????????
for($i=0; $i<26; $i++){ ${'num'.$i}=array();} //???????????? array
$i = 0;
foreach ($datafile as $i => $line){//??????????????
list($num1[$i],$num2[$i],$num3[$i],$num4[$i],$num5[$i],$num6[$i],$num7[$i],$num8[$i],$num9[$i],$num10[$i],$num11[$i],$num12[$i],$num13[$i],$num14[$i],$num15[$i],$num16[$i],$num17[$i],$num18[$i],$num19[$i],$num20[$i],$num21[$i],$num22[$i],$num23[$i],$num24[$i],$num25[$i]) = explode(',', substr($line,0)); //??????????? array
$num1[$i] = intval(substr($num1[$i],0,-2));
$num18[$i] = intval($num18[$i]); //???? colum ??????????????
$num19[$i] = intval($num19[$i]);
$num20[$i] = intval($num20[$i]);
$num21[$i] = intval($num21[$i]);
$num22[$i] = intval($num22[$i]);
$target1[$i] = 10;
$target2[$i] = 20;
$target3[$i] = 30;
$i++;
}
$T= substr($_POST["top1"],13);
$R= str_replace("H0"," MC#",$T);
$P= str_replace("E."," - ",$R);
echo ("$P");
unset($file_array) ; echo '<pre>'; //?????????
//echo 'num0 = '; echo implode(',', $num1); echo '<br>';
echo 'Loadcell-1 = '; echo implode(',', $num19); echo '<br>';
echo 'Loadcell-2 = '; echo implode(',', $num20); echo '<br>';
echo 'Loadcell-3 = '; echo implode(',', $num21); echo '<br>';
echo 'Loadcell-4 = '; echo implode(',', $num22); echo '</pre>';
?>
]
|
|
|
|
|
Date :
2021-03-14 02:08:09 |
By :
mini |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอบความคิดเห็นที่ : 7 เขียนโดย : mini เมื่อวันที่ 2021-03-14 02:08:09
form ครับ
รายละเอียดของการตอบ ::
... ใส่ความคิดเห็นตรงนี้....... Code (PHP)
<html>
<title>Map Monitor Loadcell</title>
<?php
$MT="DATA/";
$tep ="";
$line="";
$T="";
if ($handle = opendir("$MT")) {//????????????
while (($jumfile= readdir($handle)) !==false ) {
if ($jumfile !== ".." && $jumfile !== ".")
{
$T= substr($jumfile,8);
$R= str_replace("H0"," MC#",$T);
$P= str_replace("E."," - ",$R);
//echo "$i.<a href=\"$MT/$jumfile\" target=\"_blank\"> $jumfile </a><br />";
($tep=$tep."<option value=\"$MT$jumfile\">$P</option>"); //????????????
}
}
closedir($handle);
}
?>
<form method="post" action="upload.php" >
<font color="000000">Model</font>
<select name ="top" id="top" required >
<?php echo ($tep);?></option>
</select></br>
<font color="000000">Model</font>
<select name ="top1" id="top1" required >
<?php echo ($tep);?></option>
</select></br>
<button type="submit" >Summit</button>
</form></td><td>
</body>
</html>
[/quote-no
<?php
$datafile=file($_POST["top"]);//??????????????
for($i=0; $i<26; $i++){ ${'num'.$i}=array();} //???????????? array
$i = 0;
foreach ($datafile as $i => $line){//??????????????
list($num1[$i],$num2[$i],$num3[$i],$num4[$i],$num5[$i],$num6[$i],$num7[$i],$num8[$i],$num9[$i],$num10[$i],$num11[$i],$num12[$i],$num13[$i],$num14[$i],$num15[$i],$num16[$i],$num17[$i],$num18[$i],$num19[$i],$num20[$i],$num21[$i],$num22[$i],$num23[$i],$num24[$i],$num25[$i]) = explode(',', substr($line,0)); //??????????? array
$num1[$i] = intval(substr($num1[$i],0,-2));
$num18[$i] = intval($num18[$i]); //???? colum ??????????????
$num19[$i] = intval($num19[$i]);
$num20[$i] = intval($num20[$i]);
$num21[$i] = intval($num21[$i]);
$num22[$i] = intval($num22[$i]);
$target1[$i] = 10;
$target2[$i] = 20;
$target3[$i] = 30;
$i++;
}
$T= substr($_POST["top"],13);
$R= str_replace("H0"," MC#",$T);
$P= str_replace("E."," - ",$R);
echo ("$P");
unset($file_array) ; echo '<pre>'; //?????????
//echo 'num0 = '; echo implode(',', $num1); echo '<br>';
echo 'Loadcell-1 = '; echo implode(',', $num19); echo '<br>';
echo 'Loadcell-2 = '; echo implode(',', $num20); echo '<br>';
echo 'Loadcell-3 = '; echo implode(',', $num21); echo '<br>';
echo 'Loadcell-4 = '; echo implode(',', $num22); echo '</pre>';
?>
<?php
$datafile=file($_POST["top1"]);//??????????????
for($i=0; $i<26; $i++){ ${'num'.$i}=array();} //???????????? array
$i = 0;
foreach ($datafile as $i => $line){//??????????????
list($num1[$i],$num2[$i],$num3[$i],$num4[$i],$num5[$i],$num6[$i],$num7[$i],$num8[$i],$num9[$i],$num10[$i],$num11[$i],$num12[$i],$num13[$i],$num14[$i],$num15[$i],$num16[$i],$num17[$i],$num18[$i],$num19[$i],$num20[$i],$num21[$i],$num22[$i],$num23[$i],$num24[$i],$num25[$i]) = explode(',', substr($line,0)); //??????????? array
$num1[$i] = intval(substr($num1[$i],0,-2));
$num18[$i] = intval($num18[$i]); //???? colum ??????????????
$num19[$i] = intval($num19[$i]);
$num20[$i] = intval($num20[$i]);
$num21[$i] = intval($num21[$i]);
$num22[$i] = intval($num22[$i]);
$target1[$i] = 10;
$target2[$i] = 20;
$target3[$i] = 30;
$i++;
}
$T= substr($_POST["top1"],13);
$R= str_replace("H0"," MC#",$T);
$P= str_replace("E."," - ",$R);
echo ("$P");
unset($file_array) ; echo '<pre>'; //?????????
//echo 'num0 = '; echo implode(',', $num1); echo '<br>';
echo 'Loadcell-1 = '; echo implode(',', $num19); echo '<br>';
echo 'Loadcell-2 = '; echo implode(',', $num20); echo '<br>';
echo 'Loadcell-3 = '; echo implode(',', $num21); echo '<br>';
echo 'Loadcell-4 = '; echo implode(',', $num22); echo '</pre>';
?>
Code (PHP)
[php] ]
|
|
|
|
|
Date :
2021-03-14 02:11:01 |
By :
mini |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอคำแนะนำแนวคิดไหนดีครับ
|
|
|
|
|
Date :
2021-03-16 08:02:01 |
By :
mini |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|