codeigniter - Only the first row of a table updates after new details are inserted in a popup form -


in each row of table, have “insert” link. when user clicks link, popup window appears containing form. when user clicks “save” button form, form update works first row of parent table. takes first row id.

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>         </style>--> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>popup contact form using css - demo | codingcrazy</title> <link href="<?php echo base_url();?>assets/css/styleform.css" rel="stylesheet" type="text/css"/> <link href='http://fonts.googleapis.com/css?family=electrolize' rel='stylesheet' type='text/css' />  <!--cc--> <link rel="stylesheet" href="<?php echo base_url();?>assets/css/fonts.css"/> </head>   </body> </html>       <!--<link rel="stylesheet" href="<?php // echo base_url();?>assets/css/special.css" type="text/css" />--> <div class="bal" style="margin-left: 627px;     padding: 15px;">       balance amount:<input type="text" name="bal">     <?php echo form_open('money_c/addrow')?>     <input type="submit" style="padding:7px;" name="sub" value="add row">  <?php echo form_close();?></div>      <table border="1">       <tr>                         <th>date</th>                <th>description</th>                               <th>category</th>                               <th>debit</th>                                  <th>credit</th>                                     <th>bal.amt</th>                                        <th>insert</th>                                        <th> edit/delete</th></tr>              <?php foreach($query2 $row)            {                 $date=$row->date;                $desc=$row->description;                $credit=$row->credit;                $deb=$row->debit;                $bal=$row->bal;                $cat=$row->category;                $id=$row->id;            ?>                  <tr><td><?php echo $date;?></td>         <td><?php echo $desc;?></td>         <td><?php echo $credit;?></td>         <td><?php echo $deb;?></td>         <td><?php echo $bal;?></td>         <td><?php echo $cat;?></td>          <td><a href="#pop" >insert<div id="pop" class="box">           <?php              ?> <!--<form action="" method="post" class="smart-green">-->     <div class="smart-green">      <?php       echo form_open('money_c/manualupdatesave/'.$id)?>///here updation happens first row id;     <h1>         <span>please fill texts in fields.</span>     </h1>     <label>         <span>date:</span>         <input type="date" name="dat"  />     </label>       <label>         <span>description:</span>         <input name="desc" type="text" />     </label>     <label>         <span>category:</span><select name="selection">           <?php foreach($query1 $row1)             {                  $cat=$row1->category;                 ?>         <!--<option value="job inquiry">job inquiry</option>-->         <option value="<?php echo $cat;?>"><?php echo$cat;?></option>          <?php             }             ?>         </select>     </label>       <label>         <span>debit:</span>         <input type="text" name="deb"></input>     </label>       <label>         <span>credit:</span>         <input type="text" name="credit"></input>     </label>        <label>         <span>&nbsp;</span>          <input type="submit" style="margin-top:12px" class="button" style="background-color: #004e98;"value="send" />      </label>       </div> <?php echo form_close();?> <!--</form>--> <div id="close">            <td><a href="<?php echo site_url('money_c/manualdelete/'.$id);?>"><img src="<?php echo base_url();?>assets/images/del.jpg" width="60" height="40"></a></td>                    </tr>                 <?php            }            ?></table>      </tbody> </table> 

my controller:

money_c  function manualupdatesave($id)     {         $a=$this->input->post('dat');         $b=$this->input->post('desc');         $c=$this->input->post('cat');           $d=$this->input->post('deb');             $e=$this->input->post('credit');         $this->money_m->transaction($a,$b,$c,$d,$e,$id);           $this->load->view('header');          $result['query2'] = $this->money_m->selecttrans();            $this->load->view('manualupdate',$result);               $this->load->view('footer');          } 

view page: manualupdate.php:

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>         </style>--> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>popup contact form using css - demo | codingcrazy</title> <link href="<?php echo base_url();?>assets/css/styleform.css" rel="stylesheet" type="text/css"/> <link href='http://fonts.googleapis.com/css?family=electrolize' rel='stylesheet' type='text/css' />  <!--cc--> <link rel="stylesheet" href="<?php echo base_url();?>assets/css/fonts.css"/> </head>       <!--<link rel="stylesheet" href="<?php // echo base_url();?>assets/css/special.css" type="text/css" />--> <div class="bal" style="margin-left: 627px;     padding: 15px;">       balance amount:<input type="text" name="bal">     <?php echo form_open('money_c/addrow')?>     <input type="submit" style="padding:7px;" name="sub" value="add row">  <?php echo form_close();?></div>      <table border="1">       <tr>                         <th>date</th>                <th>description</th>                               <th>category</th>                               <th>debit</th>                                  <th>credit</th>                                     <th>bal.amt</th>                                        <th>insert</th>                                        <th> edit/delete</th></tr>              <?php foreach($query2 $row)            {                 $date=$row->date;                $desc=$row->description;                $credit=$row->credit;                $deb=$row->debit;                $bal=$row->bal;                $cat=$row->category;                $id=$row->id;            ?>                  <tr><td><?php echo $date;?></td>         <td><?php echo $desc;?></td>         <td><?php echo $credit;?></td>         <td><?php echo $deb;?></td>         <td><?php echo $bal;?></td>         <td><?php echo $cat;?></td>          <td><a href="#pop" >insert<div id="pop" class="box">           <?php              ?> <!--<form action="" method="post" class="smart-green">-->     <div class="smart-green">      <?php       echo form_open('money_c/manualupdatesave/'.$id)?>     <h1>         <span>please fill texts in fields.</span>     </h1>     <label>         <span>date:</span>         <input type="date" name="dat"  />     </label>       <label>         <span>description:</span>         <input name="desc" type="text" />     </label>     <label>         <span>category:</span><select name="selection">           <?php foreach($query1 $row1)             {                  $cat=$row1->category;                 ?>         <!--<option value="job inquiry">job inquiry</option>-->         <option value="<?php echo $cat;?>"><?php echo$cat;?></option>          <?php             }             ?>         </select>     </label>       <label>         <span>debit:</span>         <input type="text" name="deb"></input>     </label>       <label>         <span>credit:</span>         <input type="text" name="credit"></input>     </label>        <label>         <span>&nbsp;</span>          <input type="submit" style="margin-top:12px" class="button" style="background-color: #004e98;"value="send" />      </label>       </div> <?php echo form_close();?> <!--</form>--> <div id="close">            <td><a href="<?php echo site_url('money_c/manualdelete/'.$id);?>"><img src="<?php echo base_url();?>assets/images/del.jpg" width="60" height="40"></a></td>                    </tr>                 <?php            }            ?></table>      </tbody> </table> 

my popup form:

 <?php       echo form_open('money_c/manualupdatesave/'.$id)?>     <h1>         <span>please fill texts in fields.</span>     </h1>     <label>         <span>date:</span>         <input type="date" name="dat"  />     </label>       <label>         <span>description:</span>         <input name="desc" type="text" />     </label>     <label>         <span>category:</span><select name="selection">           <?php foreach($query1 $row1)             {                  $cat=$row1->category;                 ?>         <!--<option value="job inquiry">job inquiry</option>-->         <option value="<?php echo $cat;?>"><?php echo$cat;?></option>          <?php             }             ?>         </select>     </label>       <label>         <span>debit:</span>         <input type="text" name="deb"></input>     </label>       <label>         <span>credit:</span>         <input type="text" name="credit"></input>     </label>        <label>         <span>&nbsp;</span>          <input type="submit" style="margin-top:12px" class="button" style="background-color: #004e98;"value="send" />      </label>       </div> <?php echo form_close();?> 


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -