โดย suree » 20/01/2007 11:16 am
ใช้เรียกตาราง ที่เราต้องการ มาแสดงผลครับ โค้ดทั้งหมดเป็นแบบนี้ครับ เมื่อกี้ไฟดับ เลยโพสใหม่ ตอบกระทู้ อาจซ้ำกันนะครับ
<?php
$dsn = "phptbhdb";
$uid ="";
$pwd = "";
$fn = odbc_connect($dsn,$uid,$pwd);
$sql= "select id_card ,prename,fname,lname,birthdate from person";
//$sql= "select * from person";
$rn = odbc_exec($fn,$sql);
$nf = odbc_num_fields($rn);
$nr = odbc_num_rows($rn);
echo "<table border = 1><tr>";
//for($I = 1;$I <=$nf;$I++){
//echo "<td>",$I,".",odbc_field_name($rn,$I),"</td>";
//}
echo "<td align=center>","เลขที่","</td>";
echo "<td align=center>","คำนำหน้า","</td>";
echo "<td align=center>","ชื่อ","</td>";
echo "<td align=center>","นามสกุล","</td>";
echo "<td align=center>","วันเดือนปีเกิด","</td>";
do {
echo "</tr>";
for($I=1;$I<=$nf;$I++){
if ($I == 5) {
$a = (odbc_result($rn,$I));
// $a = date('Y',$a);
// $a = $a+543 ;
// print date("d.m.Y",$mk1);
echo "<td>",$a,"</td>";
// $a = $b;
}
else {
echo "<td>",odbc_result($rn,$I),"</td>";
}
}
echo "</tr>";
}
while(odbc_fetch_Row($rn));
echo "</table>";
?>
ใช้เรียกตาราง ที่เราต้องการ มาแสดงผลครับ โค้ดทั้งหมดเป็นแบบนี้ครับ เมื่อกี้ไฟดับ เลยโพสใหม่ ตอบกระทู้ อาจซ้ำกันนะครับ
<?php
$dsn = "phptbhdb";
$uid ="";
$pwd = "";
$fn = odbc_connect($dsn,$uid,$pwd);
$sql= "select id_card ,prename,fname,lname,birthdate from person";
//$sql= "select * from person";
$rn = odbc_exec($fn,$sql);
$nf = odbc_num_fields($rn);
$nr = odbc_num_rows($rn);
echo "<table border = 1><tr>";
//for($I = 1;$I <=$nf;$I++){
//echo "<td>",$I,".",odbc_field_name($rn,$I),"</td>";
//}
echo "<td align=center>","เลขที่","</td>";
echo "<td align=center>","คำนำหน้า","</td>";
echo "<td align=center>","ชื่อ","</td>";
echo "<td align=center>","นามสกุล","</td>";
echo "<td align=center>","วันเดือนปีเกิด","</td>";
do {
echo "</tr>";
for($I=1;$I<=$nf;$I++){
if ($I == 5) {
$a = (odbc_result($rn,$I));
// $a = date('Y',$a);
// $a = $a+543 ;
// print date("d.m.Y",$mk1);
echo "<td>",$a,"</td>";
// $a = $b;
}
else {
echo "<td>",odbc_result($rn,$I),"</td>";
}
}
echo "</tr>";
}
while(odbc_fetch_Row($rn));
echo "</table>";
?>