Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php-为表中的每个字段填充产品_Php_Mysql - Fatal编程技术网

php-为表中的每个字段填充产品

php-为表中的每个字段填充产品,php,mysql,Php,Mysql,我正在尝试填充表中的客户信息。我用下面的代码实现了这一点。我的问题是,在最后一列中,我有带有复选框的产品列表。我的编码方式仅为表中的第一个字段(customer)填充。我希望它具有每个字段的唯一id,因为我计划传递POST函数,在SQL中创建一行,在那里我可以将产品分配给客户。有什么想法可以实现这一点吗?谢谢 <table border="1" cellpadding="5" cellspacing="0" class="list" id="assign"> <th

我正在尝试填充表中的客户信息。我用下面的代码实现了这一点。我的问题是,在最后一列中,我有带有复选框的产品列表。我的编码方式仅为表中的第一个字段(customer)填充。我希望它具有每个字段的唯一id,因为我计划传递POST函数,在SQL中创建一行,在那里我可以将产品分配给客户。有什么想法可以实现这一点吗?谢谢

    <table border="1" cellpadding="5" cellspacing="0" class="list" id="assign">
  <thead>
    <tr>
      <td class="left">First Name</td>
      <td class="left">Last Name</td>
      <td class="left">E-mail</td>
      <td class="left">Assign Product</td>
       </tr>
  </thead>
  <tbody>
    <?php
      if( mysql_num_rows( $selectRes )==0 ){
        echo '<tr><td colspan="4" class="left">No Rows Returned</td></tr>';
      }else{
        while( $row = mysql_fetch_assoc( $selectRes ) ){
          echo "<tr><td class='left'>{$row['firstname']}</td><td class='left'>{$row['lastname']}</td><td class='left'>{$row['email']}</td><td><div class='layer'><p class='heading'>Edit</p>";
        }
      }
       if( !( $selectRes2 = mysql_query( $selectSQL2 ) ) ){
    echo 'Retrieval of data from Database Failed - #'.mysql_errno().': '.mysql_error();
  }else{  }
   ?> 

   <div class='area'>
   <div class='scrollbox'>
   <?php
  if( mysql_num_rows( $selectRes2 )==0 ){
        echo '<div>No Rows Returned</div>';
      }else{
        while( $row = mysql_fetch_assoc( $selectRes2 ) ){
          echo "<div id='inline'><input type='checkbox'></input>{$row['name']}</div>";
         } echo "<input type='submit' value='Submit'></input>";
      } 
          ?>            
        </div>
    </div>
  </div>

    </td></tr>
  </tbody>
</table>

名字
姓
电子邮件
分配产品

您已经考虑过了,只需将id添加到复选框的名称中,您甚至可以在它前面加上类似“CHK_”的前缀,并用处理表单帖子的代码将其解析出来

    echo "<div id='inline'><input type='checkbox' name='CHK_{$row['id']}'></input>{$row['name']}</div>";
echo“{$row['name']}”;

那么,只需输入同样神奇的“修复”代码即可。应该这样做。