จะสร้างปุ่ม เคลียร์ค่าค้นหาเเล้วกลับไปหน้าเดิมค่ะ ได้ปุ่มเคลียร์มาเเต่ค้นหาไม่ได

สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network

Moderators: mindphp, ผู้ดูแลกระดาน

thatsawan
PHP VIP Members
PHP VIP Members
Posts: 19892
Joined: 31/03/2014 10:02 am
Contact:

จะสร้างปุ่ม เคลียร์ค่าค้นหาเเล้วกลับไปหน้าเดิมค่ะ ได้ปุ่มเคลียร์มาเเต่ค้นหาไม่ได

Post by thatsawan » 15/11/2014 12:36 pm

Code: Select all

<form id="acp_active_topic_short_name" method="post" action="{SEARCH_ACTION}">
<fieldset class="display-options search-box">
	{L_SEARCH_KEYWORDS}{L_COLON} <input type="text" name="search" value="{SEARCH_WORDS}" />&nbsp;<input type="submit" class="button2" name="filter" value="{L_SEARCH}" />
        <input type="hidden" id="submit" name="action" value="{U_ACTION}" />
        <input class="button1" type="submit" id="submit" name="submit" value="{L_SUBMIT}" />
</fieldset>
<table id="down" class="table1 zebra-table responsive">
    <thead>
        <tr>
            <th>{L_ID_FORUM}</th>
            <th>{L_NAME_FORUM}</th>
            <th>{L_FORUM_SHORT_NAME}</th>
            <th>{L_SETTING}</th>
        </tr>
        <!-- BEGIN row -->
        <tr>
            <td>{row.FORUM_ID}</td>
            <td>{row.FORUM_NAME}</td>
            <td>{row.FORUM_SHORT_NAME}</td>
            <td><a href="{row.EDIT_SHORT_NAME}">{L_EDIT}</a></td>
            <!--<td><a href="{row.EDIT_SHORT_NAME} " data-ajax="row_delete">{L_DEL}</a></td>-->
        </tr>
        <!-- END row -->
    </thead>
</table>  
</form>

thatsawan
PHP VIP Members
PHP VIP Members
Posts: 19892
Joined: 31/03/2014 10:02 am
Contact:

Re: จะสร้างปุ่ม เคลียร์ค่าค้นหาเเล้วกลับไปหน้าเดิมค่ะ ได้ปุ่มเคลียร์มาเเต่ค้นหาไม่ได

Post by thatsawan » 15/11/2014 12:40 pm

[code=php]<?php


namespace mdsoft\m_active_topic_forum_short_name\acp;

class m_active_topic_forum_short_name_module
{
    var $u_action;

    function main($id, $mode)
    {                
        global $db, $user, $auth, $template, $cache, $request ,$phpbb_container;
        global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
                $pagination = $phpbb_container->get('pagination');
                //sprint_r($config); exit;
        $user->add_lang_ext('mdsoft/m_active_topic_forum_short_name', 'acp/info_acp_active_topic_forum_short_name');
        $this->config   = $config;
        $this->request  = $request;
                $this->tpl_name = 'acp_active_topic_forum_short_name';
                $action         = request_var('action', '');
                $search         = request_var('search','');
                $start          = request_var('start',0);
                $per_page = request_var('short_page', 3); //$config['topics_per_page']
                if (empty($search)){
                        $sql_ary = array(
                        'SELECT'    => '*',
                        'FROM'      => array(
                                FORUMS_TABLE         => 'f',
                                ),
                        );
                        $sql = $db->sql_build_query('SELECT', $sql_ary);
                        $result = $db->sql_query_limit($sql, $per_page, $start);
                                while($row = $db->sql_fetchrow($result)){
                                $forum_id =  $row['forum_id'];  
                                $template->assign_block_vars('row', array(
                                        'FORUM_ID'                      => $forum_id,
                                        'FORUM_NAME'                    => $row['forum_name'],
                                        'FORUM_SHORT_NAME'              => $row['forum_short_name'],
                                        'EDIT_SHORT_NAME'               => "{$this->u_action}&action=show_name&forum_id=$forum_id",
                                ));} 
                        
                        $sql_ary['SELECT'] = 'COUNT(f.forum_id) as total_forum';
                        $sql = $db->sql_build_query('SELECT', $sql_ary);
                        $result = $db->sql_query($sql);
                        $total_forums = $db->sql_fetchfield('total_forum');
                        $db->sql_freeresult($result);

                      //  $base_url =  $this->u_action . "&short_page=$per_page";
                        $base_url =  $this->u_action ;
                        $pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_forums,$per_page,$start);
                }     
                
                switch ($action)
                {       
                        case 'search' :
                        if(empty($search)){
                            trigger_error($user->lang['ACP_SEARCH_SHORT'] . adm_back_link($this->u_action), E_USER_WARNING);
                        }
                        
                        $sql_ary = array(
                        'SELECT'    => '*',
                        'FROM'      => array(
                                FORUMS_TABLE         => 'f',
                                ),
                        'WHERE' => " forum_id LIKE '" .  $db->sql_escape(utf8_clean_string($search)). "' OR forum_name LIKE '%" . $db->sql_escape(utf8_clean_string($search))."%'OR forum_short_name LIKE '%" . $db->sql_escape(utf8_clean_string($search))."%'",
                        );
                         $sql = $db->sql_build_query('SELECT', $sql_ary);
                         $result = $db->sql_query_limit($sql, $per_page, $start);
                         while($row = $db->sql_fetchrow($result)){
                                $forum_id =  $row['forum_id'];
                                $template->assign_block_vars('row', array(
                                        'FORUM_ID'                      => $forum_id,
                                        'FORUM_NAME'                    => $row['forum_name'],
                                        'FORUM_SHORT_NAME'              => $row['forum_short_name'],
                                ));}   
                                
                        $template->assign_vars(array(
                                'SEARCH_WORDS'    => $search,
                                'SHOWLIST'   => TRUE,
                                'SHOWFORM'   => FALSE,
                                'SEARCH_ACTION'  =>  $this->u_action .'&action=search',
                        ));
                                
                        $sql_ary['SELECT'] = 'COUNT(f.forum_id) as total_forum_search';
                        $sql = $db->sql_build_query('SELECT', $sql_ary);
                        $result = $db->sql_query($sql);
                        $total_forums_search = $db->sql_fetchfield('total_forum_search');
                        $db->sql_freeresult($result);
                        /*ส่งค่ากลับเหมือนกับรับจากฟอร์ม */
                        $base_url_search =  $this->u_action . "&action=$action&search=$search";
                        $pagination->generate_template_pagination($base_url_search, 'pagination', 'start', $total_forums_search,$per_page,$start);
                        
                        break;
                        case 'show_name' :      
                        $forum_id = request_var('forum_id', 0);  
                        $forum_short_name = request_var('forum_short_name','');
                        $sql = 'SELECT * FROM ' . FORUMS_TABLE . ' WHERE forum_id ='. $forum_id ;
                        $result = $db->sql_query($sql);
                        $row    = $db->sql_fetchrow($result);
                        $template->assign_vars(array(
                                'FORUM_ID'              => $forum_id,
                                'FORUM_NAME'            => $row['forum_name'],
                                'FORUM_SHORT_NAME'      => $row['forum_short_name'],
                                'SHOWLIST'              => FALSE,
                                'SHOWFORM'              => TRUE,
                                'MODE'                  => 'save',
                        ));
                        break;
                        case 'edit' :            
                                $template->assign_vars(array(
                                'SHOWLIST'   => FALSE,
                                'SHOWFORM'   => TRUE,
                                'MODE'       => 'save',
                        ));
                        break;
                        case 'save':
                                $forum_id               = request_var('forum_id', 0);  
                                $forum_name             = request_var('forum_name','',true);
                                $forum_short_name       = request_var('forum_short_name','',true);
                                $sql_arr        = array(
                                        'forum_id '             => $forum_id ,
                                        'forum_short_name'      => $forum_short_name,
                                );
                                $sql = ' UPDATE '.FORUMS_TABLE.' SET '.$db->sql_build_array('UPDATE',$sql_arr).' WHERE forum_id = '.$forum_id;
                               //echo $sql; exit;
                                $db->sql_query($sql); 
                                //$message = $user->lang['SUCCESS_UPDATED'];
                                meta_refresh(2, $this->u_action);
                                trigger_error($user->lang['SUCCESS_UPDATED'] . adm_back_link($this->u_action));      
                        default : 
                        $template->assign_vars(array(
                            'SHOWLIST'      =>  TRUE,
                            'SHOWFORM'      =>  FALSE,
                            'U_ACTION'      =>  $this->u_action .'&action=edit',
                            'SEARCH_ACTION'  =>  $this->u_action .'&action=search',
                            'SUB_MODE'      => 'edit',
                        ));
                }
               
        }
} [/code]

User avatar
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
Posts: 22577
Joined: 22/09/2008 6:18 pm
Contact:

Re: จะสร้างปุ่ม เคลียร์ค่าค้นหาเเล้วกลับไปหน้าเดิมค่ะ ได้ปุ่มเคลียร์มาเเต่ค้นหาไม่ได

Post by mindphp » 16/11/2014 7:49 pm

เคลียร์ค่าค้นหาเเล้วกลับไปหน้าเดิม
ใช้ javascript , หรือ php redirect หรือ เขียน php ให้ใช้เงื่อนไข เหมือนมี การส่งค่าว่างเข้าไป
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042

Post Reply

Return to “Programming - PHP”

Users browsing this forum: Google [Bot] and 21 guests