|
 |
|
ถามเรื่องการ SELECT SQL ครับ ผมทำโมดูลใน Drupal มีปัญหาการ SELECT ไม่รู้จะเรียกข้อมูลยังไง |
|
 |
|
|
 |
 |
|
ผมทำโมดูลใน Drupal มีปัญหาการ SELECT ไม่รู้จะเรียกข้อมูลยังไง เพราะว่า ใน 1 Record นั้นมี 2 user_id ผมสามารถเรียกให้แสดง uid ได้ แต่ว่าที่ผมต้องการคือเอาชื่อผู้ใช้มาแสดง พูดไม่ค่อยเก่งขออธิบายด้วยรูปนะครับ
ข้างล่างนี้เป็น DB ครับ

อันนี้ โค้ตเดิมนะครับ อันที่แก้ผมลบไปหมดแล้ว ============
Code
<?
$output =' ';
$sql = "SELECT cgname, u_name, u_name2 FROM {cg}";
$limit = 20;
$header = array(
array('data' => t('ชื่อสาขา'), 'field' => 'cgname'),
array('data' => t('หัวหน้า'), 'field' => 'u_name' ),
array('data' => t('รองหัวหน้า'), 'field' => 'u_name2' )
);
$tablesort = tablesort_sql ($header);
$result = pager_query($sql . $tablesort,$limit);
$rows = array();
//$p_user = array();
while ( $item = db_fetch_object ( $result )) {
$rows [] = array(
( $item -> cgname),
( $item -> u_name),
( $item -> u_name2 ));
};
if (! $rows ) {
$rows [] = array(array( 'data' => t( '' ), 'colspan' => 3 ));
}
$output .= theme ( 'table' , $header , $rows );
$output .= theme ( 'pager' , NULL , $limit , 10 );
return $output ;
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2010-02-17 22:01:24 |
By :
plangao |
View :
1160 |
Reply :
0 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 05
|