Welcome Guest, Not a member yet? Register   Sign In
problem with delete row on mysql
#1

[eluser]SaSa[/eluser]
hello
i want delete row on mysql but is a problem, i can not get input checkbox on viwe page by $this->input->post.
whay?
my CI_Controller:

Code:
$id = $this->input->post('checkbox');
$checkbox = $this->db->where('code', $id);
$this->db->delete('customer');
$date ['date'] = print_r($checkbox);
$this->load->view('admin/customer_size_show', $date);

my viwe page:

Code:
$query = $this->db->get('customer');
            foreach ($query->result() as $row)
            {
        
        echo '<table id="tableeven" border="0" cellpadding="0" cellspacing="0">';
        echo '<tr><td>&lt;input name="checkbox" type="checkbox" value="'.$row-&gt;code.'"></td>';
        echo '<td class="tableshow_in">'.$row->name.'</td>';
        echo '<td class="tableshow_in">' .$row->mail. '</td>';
        echo '<td class="tableshow_in">' .$row->tel. '</td>';
        echo '<td class="tableshow_in">' .$row->date_added. '</td>';
        echo '<td class="tableshow_in">' .$row->order. '</td>';
        echo '<td class="tableshow_in">' .$row->code. '</td></tr>';
            echo '</table>';
        }

print_r:
Quote:CI_DB_mysql_driver Object ( [dbdriver] => mysql [_escape_char] => ` [_like_escape_str] => [_like_escape_chr] => [delete_hack] => 1 [_count_string] => SELECT COUNT(*) AS [_random_keyword] => RAND() [ar_select] => Array ( ) [ar_distinct] => [ar_from] => Array ( ) [ar_join] => Array ( ) [ar_where] => Array ( ) [ar_like] => Array ( ) [ar_groupby] => Array ( ) [ar_having] => Array ( ) [ar_keys] => Array ( ) [ar_limit] => [ar_offset] => [ar_order] => [ar_orderby] => Array ( ) [ar_set] => Array ( ) [ar_wherein] => Array ( ) [ar_aliased_tables] => Array ( ) [ar_store_array] => Array ( ) [ar_caching] => [ar_cache_exists] => Array ( ) [ar_cache_select] => Array ( ) [ar_cache_from] => Array ( ) [ar_cache_join] => Array ( ) [ar_cache_where] => Array ( ) [ar_cache_like] => Array ( ) [ar_cache_groupby] => Array ( ) [ar_cache_having] => Array ( ) [ar_cache_orderby] => Array ( ) [ar_cache_set] => Array ( ) [username] => root [password] => [hostname] => localhost [database] => diba [dbprefix] => [char_set] => utf8 [dbcollat] => utf8_general_ci [autoinit] => 1 [swap_pre] => [port] => [pconnect] => 1 [conn_id] => Resource id #32 [result_id] => 1 [db_debug] => 1 [benchmark] => 0.0010581016540527 [query_count] => 2 [bind_marker] => ? [save_queries] => 1 [queries] => Array ( [0] => SELECT * FROM (`ci_sessions`) WHERE `session_id` = 'e5119722e251b1fc23e5eeec0ed2b93f' AND `user_agent` = 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.24 (K' [1] => DELETE FROM `customer` WHERE `code` = 0 ) [query_times] => Array ( [0] => 0.00049614906311035 [1] => 0.00056195259094238 ) [data_cache] => Array ( ) [trans_enabled] => 1 [trans_strict] => 1 [_trans_depth] => 0 [_trans_status] => 1 [cache_on] => [cachedir] => [cache_autodel] => [CACHE] => [_protect_identifiers] => 1 [_reserved_identifiers] => Array ( [0] => * ) [stmt_id] => [curs_id] => [limit_used] => [stricton] => )

Code:
... DELETE FROM `customer` WHERE `code` = 0 ...
#2

[eluser]bgreene[/eluser]
&lt;input name="checkbox" type="checkbox" value="1" id="'.$row-&gt;code.'">;
#3

[eluser]SaSa[/eluser]
[quote author="bgreene" date="1305830542"]&lt;input name="checkbox" type="checkbox" value="1" id="'.$row-&gt;code.'">;[/quote]
i change but not work!?
#4

[eluser]bgreene[/eluser]
<tr>&lt;input type="hidden" name="code" value=".$row-&gt;code."/><....></tr>
#5

[eluser]SaSa[/eluser]
not work, please help me...
#6

[eluser]bgreene[/eluser]
are u getting the correct values back from the form? what does log_message('debug', print_r($this->input->post(),true)) show?
#7

[eluser]InsiteFX[/eluser]
Checkboxes If they are not ticked, they have no value at all, so nothing is returned! If you try the code without checking if the checkboxes are set, then you'll have to deal with a lot of "Undefined" errors.
Code:
echo var_dump($this->input->post('checkbox'));

InsiteFX
#8

[eluser]SaSa[/eluser]
my viwe code-full:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;

&lt;head&gt;
    &lt;title&gt;--&lt;/title&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
    &lt;link rel="stylesheet" href="&lt;?php echo base_url();?&gt;files/css/admin_style.css" /&gt;
        [removed][removed]
    [removed][removed]
&lt;/head&gt;

&lt;body&gt;&lt;center>
<ul id="nav">
    <li class="current"><a href="#">home</a></li>
    <li><a href="#">-------</a><div class="line_menu"></div></li>
    <li><a href="#">----------</a><div class="line_menu"></div></li>
    <li><a href="#">----------</a><div class="line_menu"></div></li>
    <li><a href="#">-------------</a><div class="line_menu"></div></li>
</ul>
<div class="logo_sibesabz"></div>

<div class="main_indexadmin">
    <div class="top_mainindexadmin">
            <div class="home_i"></div>
        <div class="print_i"></div>
        <div class="edit_i"></div>
        <a href="&lt;?php echo base_url();?&gt;index.php/admin/customer_size/delete" class="delete_i"></a>
        <a href="&lt;?php echo base_url();?&gt;index.php/admin/customer_size/add" class="add_i"></a>
        </div>
        
        <div class="line_right"></div>
        <div class="line_left"></div>
    <div class="table_show">
        <div class="tableshow_head">name</div>
        <div class="tableshow_head">mail</div>
        <div class="tableshow_head">tell</div>
        <div class="tableshow_head">data</div>
        <div class="tableshow_head">order</div>
        <div class="tableshow_head">code</div>
    
        &lt;?php
            $query = $this->db->get('customer');
            foreach ($query->result() as $row)
            {
        
        echo '<table id="tableeven" border="0" cellpadding="0" cellspacing="0">';
        echo '<tr><td>&lt;input name="checkbox" type="checkbox" value="'.$row-&gt;code.'"></td>';
        echo '<td class="tableshow_in">'.$row->name.'</td>';
        echo '<td class="tableshow_in">' .$row->mail. '</td>';
        echo '<td class="tableshow_in">' .$row->tel. '</td>';
        echo '<td class="tableshow_in">' .$row->date_added. '</td>';
        echo '<td class="tableshow_in">' .$row->order. '</td>';
        echo '<td class="tableshow_in">' .$row->code. '</td></tr>';
            echo '</table>';
        }
        ?&gt;
    </div>
    <div class="bottom_mainindexadmin"></div>
</div>
        
    
</div>
</center>&lt;/body&gt;
&lt;/html&gt;
please help
#9

[eluser]bgreene[/eluser]
you're not posting any data, just going to an address. you need to surround the group of tables with &lt;form action=etc&gt;yourtables and buttons&lt;/form&gt; use chrome->tools->developertools->network or firefox->httpfox to view the data being sent back to the server




Theme © iAndrew 2016 - Forum software by © MyBB