โดย thatsawan » 10/12/2014 11:19 pm
- 2014-12-10_23-20-29.png (33.1 KiB) Viewed 342 times
ตัวอย่างคำสั่งดึงข้อมูลมาเเสดง
โค้ด: เลือกทั้งหมด
$sql_ary = array (
'SELECT' => '*',
'FROM' =>array(
'phpbb_m_topic_portal' => 't'
),
);
$sql = $db->sql_build_query('SELECT',$sql_ary);
$result = $db->sql_query_limit($sql, $per_page, $start);
while ($row = $db->sql_fetchrow($result)){
$id = $row['id'];
$template->assign_block_vars('row',array(
'LABEL_ID' => $id,
'LABEL_A' => $row['topic_id'],
'LABEL_B' => $row['add_by'],
'LABEL_C' => $row['add_time'],
'LABEL_D' => $row['potal_order'],
'LABEL_E' => $row['show_topic'],
'EDIT_DATA' => "{$this->u_action}&action=show_data&id=$id",
'DEL_DATA' => "{$this->u_action}&action=del&id=$id" // ส่ง action ไปเพื่อทำการลบ
));
}
หน้าฟอร์มเเสดงข้อมูล
โค้ด: เลือกทั้งหมด
<table>
<th>{L_ID}</th>
<th>{L_LABEL_A}</th>
<th>{L_LABEL_B}</th>
<th>{L_LABEL_C}</th>
<th>{L_LABEL_D}</th>
<th colspan="2" >{L_EDIT}</th>
<!-- BEGIN row -->
<tr>
<td>{row.LABEL_ID}</td>
<td>{row.LABEL_A}</td>
<td>{row.LABEL_B}</td>
<td>{row.LABEL_C}</td>
<td>{row.LABEL_D}</td>
<td style="text-align: center;">
<a href="{row.EDIT_DATA}" >{ICON_EDIT}</a>
</td>
<td style="text-align: center;">
<a href="{row.DEL_DATA}" >{ICON_DELETE}</a>
</td>
</tr>
<!-- END row -->
</table>
รับค่า action จากที่ส่งมาเพื่อทำการลบข้อมูลเเละรับค่า ID ที่จะลบ
โค้ด: เลือกทั้งหมด
$action = request_var('action', '');
$id = request_var('id', 0); //
switch ($action){ เมื่อคลิกลบ ครั้งเเรกที่เรามาจะทำงานที่ else ก่อน
case 'del' :
if(confirm_box(ture)){
$sql = ' DELETE FROM phpbb_m_topic_portal WHERE id = '.$id ;
$db->sql_query($sql);
} else {// แสดงกล่องข้อความ เพื่อให้เรา คลิก confirm ก่อนลบ
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
'mode' => $mode,
'id' => $id,
'action' => 'del', //ถ้าเราคลิก Yes จะส่งกลับไปที่ action "confirm_box(ture)"
)));
}
trigger_error($user->lang['DEL_DATA'] . adm_back_link($this->u_action)); // เมื่อทำการลบเสร็จจะเเสดงข้อความ "ลบข้อมูลเรียบร้อยเเล้ว"
break;
}
ไฟล์ภาษาที่เราให้เเสดงคำเเจ้งเตือน
[attachment=0]2014-12-10_23-20-29.png[/attachment]
ตัวอย่างคำสั่งดึงข้อมูลมาเเสดง
[code=php]
$sql_ary = array (
'SELECT' => '*',
'FROM' =>array(
'phpbb_m_topic_portal' => 't'
),
);
$sql = $db->sql_build_query('SELECT',$sql_ary);
$result = $db->sql_query_limit($sql, $per_page, $start);
while ($row = $db->sql_fetchrow($result)){
$id = $row['id'];
$template->assign_block_vars('row',array(
'LABEL_ID' => $id,
'LABEL_A' => $row['topic_id'],
'LABEL_B' => $row['add_by'],
'LABEL_C' => $row['add_time'],
'LABEL_D' => $row['potal_order'],
'LABEL_E' => $row['show_topic'],
'EDIT_DATA' => "{$this->u_action}&action=show_data&id=$id",
'DEL_DATA' => "{$this->u_action}&action=del&id=$id" // ส่ง action ไปเพื่อทำการลบ
));
} [/code]
หน้าฟอร์มเเสดงข้อมูล
[code] <table>
<th>{L_ID}</th>
<th>{L_LABEL_A}</th>
<th>{L_LABEL_B}</th>
<th>{L_LABEL_C}</th>
<th>{L_LABEL_D}</th>
<th colspan="2" >{L_EDIT}</th>
<!-- BEGIN row -->
<tr>
<td>{row.LABEL_ID}</td>
<td>{row.LABEL_A}</td>
<td>{row.LABEL_B}</td>
<td>{row.LABEL_C}</td>
<td>{row.LABEL_D}</td>
<td style="text-align: center;">
<a href="{row.EDIT_DATA}" >{ICON_EDIT}</a>
</td>
<td style="text-align: center;">
<a href="{row.DEL_DATA}" >{ICON_DELETE}</a>
</td>
</tr>
<!-- END row -->
</table>[/code]
รับค่า action จากที่ส่งมาเพื่อทำการลบข้อมูลเเละรับค่า ID ที่จะลบ
[code=php]
$action = request_var('action', '');
$id = request_var('id', 0); //
switch ($action){ เมื่อคลิกลบ ครั้งเเรกที่เรามาจะทำงานที่ else ก่อน
case 'del' :
if(confirm_box(ture)){
$sql = ' DELETE FROM phpbb_m_topic_portal WHERE id = '.$id ;
$db->sql_query($sql);
} else {// แสดงกล่องข้อความ เพื่อให้เรา คลิก confirm ก่อนลบ
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
'mode' => $mode,
'id' => $id,
'action' => 'del', //ถ้าเราคลิก Yes จะส่งกลับไปที่ action "confirm_box(ture)"
)));
}
trigger_error($user->lang['DEL_DATA'] . adm_back_link($this->u_action)); // เมื่อทำการลบเสร็จจะเเสดงข้อความ "ลบข้อมูลเรียบร้อยเเล้ว"
break;
} [/code]
ไฟล์ภาษาที่เราให้เเสดงคำเเจ้งเตือน
[code] 'DEL_DATA' => 'ลบข้อมูลเรียบร้อยเเล้ว',[/code]