?
Path : /home/admin/public_html/old/backoffice/php/ |
Current File : /home/admin/public_html/old/backoffice/php/list_data.php |
<? $root_path="../"; include($root_path."header.php"); $db_tm = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, false); $template = new Template($tpl_path); echo "<font face='MS Sans Serif' size=1>"; /* echo $TB,"<br>"; //ชื่อตารางภาษาอังกฤษ echo $TBTH,"<br>"; //ชื่อตารางภาษาไทย echo $selitem,"<P>"; //ชื่อ Group */ $sql_01 ="SELECT SQL FROM $selitem where TB_NAME='$TB' "; $result_01 = $db_tm->sql_query($sql_01); $rows_01 = $db_tm->sql_fetchrow($result_01); $sql_error = $db_tm->sql_error($result_01); $debug_text = ''; if ( $sql_error['message'] != '' ){ $debug_text .= '<br /><br />ผิดพลาดที่คำสั่ง SQL : ' . $sql_error['message']; echo $debug_text."<br>"; } //--------------------------------[Order By]--------------------------------------- $result_02 = $db_tm->sql_query($rows_01[SQL]." where 0"); $numfields = $db_tm->sql_numfields($result_02); if ((!$FI && !$AD) || ($FI=='' && $AD=='')){ $FI=0; $FN=$db_tm->sql_fieldname($offset=0,$result_02); $AD='ASC'; } for($i=0; $i<$numfields;$i++){ $fieldsname =$db_tm->sql_fieldname($offset=$i,$result_02); if ($FI==$i){ if ($AD=='ASC'){ $img='asc_order.png';} if ($AD=='DESC'){ $img='desc_order.png';} $FN=$fieldsname; } else{ $img=""; } $template->assign_block_vars('fieldnamerow', array("FIELDNAME" => $fieldsname, "OBJ" => "Javascript:OrdByCol('$i','$AD');", "IMG" => $img , "IMG_PATH" => $images_path, )); } //--------------------------------[Order By]--------------------------------------- $sql = $rows_01[SQL]." order by '$FN' $AD"; list($usec,$sec)=explode(' ',microtime()); $time_before=((float)$usec+(float)$sec); $result = $db_tm->sql_query($sql); list($usec,$sec)=explode(' ',microtime()); $time_after=((float)$usec+(float)$sec); echo "ใช้เวลาค้นหา : ",sprintf("%.3f",$time_after-$time_before)," วินาที่"; $rows = $db_tm->sql_fetchrow($result); $numrows = $db_tm->sql_numrows($result); $sql_error = $db_tm->sql_error($result); $debug_text = ''; if ( $sql_error['message'] != '' ){ $debug_text .= '<br /><br />ผิดพลาดที่คำสั่ง SQL : ' . $sql_error['message']."<br>".$sql; echo $debug_text."<br>"; } $color1="#DBEAF5"; $color2="#FFFFFF"; $class_rows=$color2; $color_over="#00CCFF"; if($numrows!=0){ for($i=0;$i<$numrows;$i++){ $class_rows=($class_rows==$color2)? $color1:$color2; $sel_all.=$rows[0]."`"; $data.="<TR bgcolor=\"$class_rows\" onmouseout=\"bgcout(this,'$class_rows')\" onmouseover=\"bgcover(this,'$color_over')\" OnClick=\"bgc(this,'$class_rows')\">"; $data.="<TD class=\"noborder\" align=\"center\"><INPUT TYPE=\"checkbox\" NAME=\"chkboxid\" OnClick=\"select_item($rows[0],this);\"></TD>"; for($n=0;$n<$numfields;$n++){ $data.="<TD class=\"noborder\" align=\"left\"><A HREF=\"\" title=\"เลือกที่รายเพื่อแก้ไข\" OnClick=\"alert('กำลังพัฒนา!!..');\">".$rows[$n]."</A></TD>"; }//for $numfields $data.="</TR>"; $rows = $db_tm->sql_fetchrow($result); }//for $numrows }else{ echo "<CENTER>ไม่มีข้อมูล</CENTER>"; $data.="<TR>"; for($n=0;$n<$numfields;$n++){ $data.="<TD class=\"noborder\"> </TD>"; } $data.="</TR>"; } $template->set_filenames(array('body' =>'list_data.tpl')); $template->assign_vars(array("STYLE" =>STYLE, "IMAGES_PATH" =>$images_path, "DATA" =>$data, "NAME_TITLE" =>$TBTH, "TB" =>$TB, "selitem" =>$selitem, "NUMROWS" =>$numrows, "SEL_ALL" =>$sel_all, )); $template->pparse('body'); ?>