อยากจะถามพื่อนๆๆครับ ว่าเราจะ explode ข้อมูลแล้วมาทำตารางแต่แยกคนละ Field จะทำยังงัยครับ
ก็แยกออกเป็น array ด้วย exlpode นั่นแหละ แล้วค่อยเอา array มาวนลูปสร้างตารางอีกที
ความจริงคั่นด้วย <br> มันยาวไปนะไม่ลองคั่นด้วยตัวอื่นดู เช่น , ; | จะทำงานได้เร็วกว่า
$array=explode("<br>", $data);
echo "<table>";
for ($i=0; $i<count($array); $i++) {
echo "<tr><td>$array[$i]</td></tr>";
}
echo "</table>";
http://goragod.mwfhost.com
Date :
30 พ.ย. 2549 13:28:11
By :
goragod
ขอดูโค้ด ไฟล์นี้ได้มั้ยครับ
Date :
30 พ.ย. 2549 14:22:50
By :
lozomac
<?
include("header.php");
?>
<?
include("connect.php");
$id = $_GET['id'];
$sql = "select * from cs001 where id='$id'";
$query = mysql_query($sql) or die("select error");
$row = mysql_fetch_array($query);
$num = mysql_num_rows($query);
?>
<p style="font-family: "Angsana New"; font-size: 20px"><a href="PrintReport001.php">Report CS-TRD-001-A For Print </a></p>
<table width="95%" border="1" align="center" bordercolor="#000000">
<tr bordercolor="#000000">
<td width="50%"><div align="center">
<p style="font-weight: bold; font-family: "Angsana New"; font-size: 24px">บริษัท อีแอนด์เอช พรีซิชั่น (ประเทศไทย) จำกัด</p>
<p style="font-weight: bold; font-family: "Angsana New"; font-size: 24px">E&H PRECISION (THAILAND) CO.,LTD. </p>
</div></td>
<td width="50%"><div align="center">
<p style="font-weight: bold; font-family: "Angsana New"; font-size: 24px">แบบสำรวจความจำเป็นในการฝึกอบรม ประจำปี................... </p>
<p style="font-weight: bold; font-family: "Angsana New"; font-size: 24px">Training Needs Survey As Of Year....................... </p>
</div></td>
</tr>
</table><br>
<table width="90%" border="0" align="center">
<tr>
<td width="50%"><span style="font-weight: bold">Department : <u><?
$department1_array=explode("<BR>", $row['department1all']);
for ($i=0;$i<count($department1_array);$i++){
echo $department1_array[$i]."<BR>";}?></u></span> </td>
<td width="50%"><span style="font-weight: bold">Section : ..............................................</span> </td>
</tr>
</table><br>
<table width="95%" border="1" align="center" bordercolor="#000000">
<tr>
<td width="25%" rowspan="2"><div align="center" style="font-weight: bold">Subject of Training </div></td>
<td width="7%" rowspan="2"><div align="center" style="font-weight: bold">CODE</div></td>
<td colspan="8"><div align="center"><span style="font-weight: bold">Position</span> </div></td>
<td width="11%" rowspan="2"><div align="center" style="font-weight: bold">Remark</div></td>
</tr>
<tr>
<td width="5%"><div align="center">Mgr.</div></td>
<td width="8%"><div align="center">Asst.Mgr.</div></td>
<td width="4%"><div align="center">Sup.</div></td>
<td width="8%"><div align="center">Asst.Sup.</div></td>
<td width="6%"><div align="center">Leader</div></td>
<td width="10%"><div align="center">Sub-Leader</div></td>
<td width="6%"><div align="center">Staff</div></td>
<td width="10%"><div align="center">Operator</div></td>
</tr>
<?
$sql = "select * from cs001 order by id desc";
$query = mysql_query($sql) or die ("select error");
$num = mysql_num_rows($query);
?>
<?
for($i=1;$i<=$num;$i++)
{
$row = mysql_fetch_array($query);
?>
<?
}
?>
</table>
<div align="left">
<?
echo "<table width='95%' align='center' border=1 cellspacing=2 cellpadding=1 >";
$name_array=explode("<br>", $row['adminall']);
$code_array=$row['codeall'];
$position1_array=explode("<br>", $row['position1all']);
echo "<tr>";
echo "<td width='25%' align='center' border=1 cellspacing=2 cellpadding=1><b><p align='left' style='font-family: "Angsana New"; font-size: 20px; font-weight: bold'><span style='font-style: italic'>Administration and Management</span><br /></b></td>
<td width='7%' align='center' border=1 cellspacing=2 cellpadding=1></td>";
/*echo "<td>Code</td>";
echo "<td>header</td>";
echo "<td>header</td>";
echo "<td>header</td>";*/
echo " </tr>";
for ($i=0;$i<count($name_array);$i++){
$number_name=$i+1;
echo "<tr>";
echo "<td> $number_name.$name_array[$i]</td>";
echo "<td> $number_name.$code_array[$i]</td>";
echo "<td> $number_name.$position1_array[$i]</td>";
/*echo "<td>details $number_name</td>";
echo "<td>details $number_name</td>";
echo "<td>details $number_name</td>";
echo "<td>details $number_name</td>";*/
}
echo " </tr>";
?>
</div>
<table width="95%" border="1" align="center" cellpadding="0" bordercolor="#000000">
<tr>
<td width="57%" colspan="6" rowspan="2"> </td>
<td width="16%" colspan="2" bordercolor="#000000"><div align="center">Approved</div></td>
<td width="21%" colspan="2" bordercolor="#000000"><div align="center">Checked</div></td>
<td width="6%" bordercolor="#000000"><div align="center">Issued</div></td>
</tr>
<tr>
<td colspan="2" bordercolor="#000000"><p> </p>
<p> </p></td>
<td colspan="2" bordercolor="#000000"> </td>
<td bordercolor="#000000"> </td>
</tr>
</table>
<table width="95%" border="0" align="center">
<tr>
<td width="33%"><div align="left"><span style="font-family: "Angsana New"; font-size: 20px">E&H PRECISION (THAILAND) CO.,LTD </span></div></td>
<td width="33%"><div align="center"><span style="font-family: "Angsana New"; font-size: 20px"><span style="font-family: "Angsana New""><span style="font-size: 20px">DATE 16/11/2006 </span></span></span></div></td>
<td width="34%"><div align="right"><span style="font-size: 20px; font-family: "Angsana New"">CS-TRD-001-A</span></div></td>
</tr>
</table>
<p> </p>
อันนี้ครับโค๊ด
Date :
1 ธ.ค. 2549 09:32:23
By :
tete
<? /*
include("connect.php");
$id = $_GET['id'];
$sql = "select * from cs001 where id='$id'";
$query = mysql_query($sql) or die("select error");
$row = mysql_fetch_array($query);
$num = mysql_num_rows($query);*/
?>
<p style="font-family: "Angsana New"; font-size: 20px"><a href="PrintReport001.php">Report CS-TRD-001-A For Print </a></p>
<table width="95%" border="1" align="center" bordercolor="#000000">
<tr bordercolor="#000000">
<td width="50%"><div align="center">
<p style="font-weight: bold; font-family: "Angsana New"; font-size: 24px">บริษัท อีแอนด์เอช พรีซิชั่น (ประเทศไทย) จำกัด</p>
<p style="font-weight: bold; font-family: "Angsana New"; font-size: 24px">E&H PRECISION (THAILAND) CO.,LTD. </p>
</div></td>
<td width="50%"><div align="center">
<p style="font-weight: bold; font-family: "Angsana New"; font-size: 24px">แบบสำรวจความจำเป็นในการฝึกอบรม ประจำปี................... </p>
<p style="font-weight: bold; font-family: "Angsana New"; font-size: 24px">Training Needs Survey As Of Year....................... </p>
</div></td>
</tr>
</table><br>
<table width="90%" border="0" align="center">
<tr>
<td width="50%"><span style="font-weight: bold">Department : <u><?
$department1_array=explode("<BR>", $row['department1all']);
for ($i=0;$i<count($department1_array);$i++){
echo $department1_array[$i]."<BR>";}?></u></span> </td>
<td width="50%"><span style="font-weight: bold">Section : ..............................................</span> </td>
</tr>
</table><br>
<table width="95%" border="1" align="center" bordercolor="#000000">
<tr>
<td width="25%" rowspan="2"><div align="center" style="font-weight: bold">Subject of Training </div></td>
<td width="7%" rowspan="2"><div align="center" style="font-weight: bold">CODE</div></td>
<td colspan="8"><div align="center"><span style="font-weight: bold">Position</span> </div></td>
<td width="11%" rowspan="2"><div align="center" style="font-weight: bold">Remark</div></td>
</tr>
<tr>
<td width="5%"><div align="center">Mgr.</div></td>
<td width="8%"><div align="center">Asst.Mgr.</div></td>
<td width="4%"><div align="center">Sup.</div></td>
<td width="8%"><div align="center">Asst.Sup.</div></td>
<td width="6%"><div align="center">Leader</div></td>
<td width="10%"><div align="center">Sub-Leader</div></td>
<td width="6%"><div align="center">Staff</div></td>
<td width="10%"><div align="center">Operator</div></td>
</tr>
<?
/*
#################################################################
*/
/*
$sql = "select * from cs001 order by id desc";
$query = mysql_query($sql) or die ("select error");
$num = mysql_num_rows($query);
for($i=1;$i<=$num;$i++)
{
$row = mysql_fetch_array($query);
}*/
$name = "การสอบเทียบไมโครมิเตอร์<br>การสอบเทียบไดอัลเกจ<br>การสอบเทียบเวอร์เนีย";
$code = "1011<br>1156<br>1254";
$position = "Mgr<br>Asst.Mgr<br>Sup";
$name_array=explode("<br>",$name);
$code_array=explode("<br>",$code);
$position1_array=explode("<br>", $position);
echo "<tr>";
echo "<td width='25%' align='left ><b><p align='left' style='font-family: "Angsana New"; font-size: 20px; font-weight: bold'><span style='font-style: italic'>Administration and Management</span><br /></b>1.$name_array[0]</td>";
echo "<td><br>$code_array[0]</td>";
echo "<td><br>$position1_array[0]</td>";
echo "<td><br></td>";
echo "<td><br></td>";
echo "<td> <br></td>";
echo "<td><br></td>";
echo "<td><br></td>";
echo "<td><br></td>";
echo "<td><br></td>";
echo "<td><br></td>";
echo " </tr>";
for ($i=1;$i<count($name_array);$i++){
$number_name=$i+1;
echo "<tr>";
echo "<td>$number_name.$name_array[$i]</td>";
echo "<td>$code_array[$i]</td>";
echo "<td>$position1_array[$i]</td>";
echo "<td> </td>";
echo "<td> </td>";
echo "<td> </td>";
echo "<td> </td>";
echo "<td> </td>";
echo "<td> </td>";
echo "<td> </td>";
echo "<td> </td>";
echo " </tr>";
}
/*#########################################################
*/
?>
<table width="95%" border="1" align="center" cellpadding="0" bordercolor="#000000">
<tr>
<td width="57%" colspan="6" rowspan="2"> </td>
<td width="16%" colspan="2" bordercolor="#000000"><div align="center">Approved</div></td>
<td width="21%" colspan="2" bordercolor="#000000"><div align="center">Checked</div></td>
<td width="6%" bordercolor="#000000"><div align="center">Issued</div></td>
</tr>
<tr>
<td colspan="2" bordercolor="#000000"><p> </p>
<p> </p></td>
<td colspan="2" bordercolor="#000000"> </td>
<td bordercolor="#000000"> </td>
</tr>
</table>
<table width="95%" border="0" align="center">
<tr>
<td width="33%"><div align="left"><span style="font-family: "Angsana New"; font-size: 20px">E&H PRECISION (THAILAND) CO.,LTD </span></div></td>
<td width="33%"><div align="center"><span style="font-family: "Angsana New"; font-size: 20px"><span style="font-family: "Angsana New""><span style="font-size: 20px">DATE 16/11/2006 </span></span></span></div></td>
<td width="34%"><div align="right"><span style="font-size: 20px; font-family: "Angsana New"">CS-TRD-001-A</span></div></td>
</tr>
</table>
<p> </p>
ลองรันโค้ดนี้ดูคับ เพื่อจะมองเห็นแนวทาง โค้ดใหมที่ได้ใข้ไปอยู่ในส่วนที่ /*######## นะครับ
Date :
1 ธ.ค. 2549 15:44:31
By :
lozomac
ขอบพระคุณท่าน lozomac มากๆนะครับ
จะลองดูนะครับ
Date :
1 ธ.ค. 2549 19:27:44
By :
tete
Load balance : Server 02