Php Codeigniter:如何通过表单传递动态ID值

Php Codeigniter:如何通过表单传递动态ID值,php,forms,codeigniter,Php,Forms,Codeigniter,我有下面的动态生成div集,它加载一个web商店的项目及其信息和图像,我需要在单击“btn_read”时将$row->itemcode传递给控制器,我应该怎么做 <?php $this->load->helper('url'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transi

我有下面的动态生成div集,它加载一个web商店的项目及其信息和图像,我需要在单击“btn_read”时将$row->itemcode传递给控制器,我应该怎么做

     <?php $this->load->helper('url'); 


?>
<!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>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title>diluks eCommerce - Home</title>
      <link href="<?php echo base_url();?>Public/scripts/style.css" rel="stylesheet" type="text/css" />
   </head>
   <body>
   <form action="<?php echo base_url();?>index.php/welcome_controller" method="post">
      <div class="container">
          <?php 
$userpermission = $this->session->userdata('userpermission');

if($userpermission==1){
   include 'header-admin.php'; 
}
else if($userpermission==2){
   include 'header-user.php'; 
}
else{
include 'header-guest.php';}

 ?>
         <div class="level3 clearfix">
            <?php include 'shopping-sidebar.php'; ?>
            <div class="body-content">

               <div class="image-slider">
                  <img src="<?php echo base_url();?>Public/img/main-img.png" width="785" height="220" />
               </div>
               <div class="seperate-space">
                  <div class="separate-title"><a class="bold-captions">Latest Picks</a>
                  </div>
               </div>
               <div class="items">
                <?php foreach($latestproducts as $row): ?>
   <div class="item-holder">
      <form method="POST" action="<?php echo base_url();?>index.php/Idpasser_controller/toReadMore">
            <input name="item-code" type="hidden" value="<?php echo $row->itemcode ?>" />
            <table align="center" width="256px" cellpadding="0px" cellspacing="0px">
               <tr>
                  <td class="item-info-title" align="center" height="34px"><?php echo $row->itemname; ?></td>
               </tr>
               <tr>
                  <td class="item-info" align="center" height="230px">
                     <img src="<?php echo base_url();?>Public/uploads/<?php echo $row->itemimg; ?>" width="256" height="230" />
                  </td>
               </tr>
               <tr>
                  <td class="item-info" align="center" height="34px">$<?php echo $row->itemprice; ?></td>
               </tr>
               <tr>
                  <td class="item-info" align="center" height="35px"><input type="submit" name="btn_read" class="readbtn" value="Read More" /></td>
               </tr>
            </table>
      </form>
   </div>
<?php endforeach ?> 

               </div>
            </div>
         </div>
         <div style="clear:both"></div>
         <div class="level4">
            <div class="footer-area">
               <div class="lined-space"></div>
               <div class="site-map" align="left">
                  <table>
                     <tr>
                        <td class="footer-text"><a href="#">About Us</a></td>
                        <td class="footer-text"><a href="#">Facebook</a></td>
                     </tr>
                     <tr>
                        <td class="footer-text"><a href="#">Contact Us</a></td>
                        <td class="footer-text"><a href="#">Twitter</a></td>
                     </tr>
                     <tr>
                        <td class="footer-text"><a href="#">FAQs</a></td>
                        <td class="footer-text"><a href="#">Terms & Conditions</a></td>
                     </tr>
                     <tr>
                        <td class="footer-text"><a href="#">Help</a></td>
                     </tr>
                  </table>
               </div>
               <div class="developer-info">
                  <a class="developers-text">Designed & Developed By Diluks Software Solutions.</a>
               </div>
            </div>
         </div>
      </div>
      </form>
   </body>
</html>

diluks电子商务-主页

使用表单包装表,并添加字段以传递项目代码,如

<?php foreach($latestproducts as $row): ?>
   <div class="item-holder">
      <form method="POST" action="<?php echo site_url("controller/method") ?>">
            <input name="item-code" type="hidden" value="<?php echo $row->itemcode ?>" />
            <table align="center" width="256px" cellpadding="0px" cellspacing="0px">
               <tr>
                  <td class="item-info-title" align="center" height="34px"><?php echo $row->itemname; ?></td>
               </tr>
               <tr>
                  <td class="item-info" align="center" height="230px">
                     <img src="<?php echo base_url();?>Public/uploads/<?php echo $row->itemimg; ?>" width="256" height="230" />
                  </td>
               </tr>
               <tr>
                  <td class="item-info" align="center" height="34px">$<?php echo $row->itemprice; ?></td>
               </tr>
               <tr>
                  <td class="item-info" align="center" height="35px"><input type="submit" name="btn_read" class="readbtn" value="Read More" /></td>
               </tr>
            </table>
      </form>
   </div>
<?php endforeach ?> 


我可以在一个文件中有多个表格吗?我已经有了一个表单来控制所有的事件,除了第一个项目,其他所有项目都正确地传递了ID,第一个项目没有传递任何东西是的,在这个循环之外还有一些其他的提交按钮,因此,除了第一个直接指向外部表单的问题外,您的方法是有效的。您能用完整的代码更新问题吗?至少使用您提到的作为外部表单的主表单。然后使用单独的表单包装“登录,管理面板,我的购物车”。