如何将数据存储到多个数组

时间:2016-04-29 05:41:24

标签: php mysql arrays

this is my form

如何为('algo'=>'input1','algo'=>'input2'等每一行创建数组 然后('algo2'=>'input1','algo2'=>'input2') 我想为动态主题数做这个,也想插入mysql 通过PHP。 this是我想要存储数组值的方法

 $sel=mysqli_query($db,"SELECT * from srs");
 $count=mysqli_num_rows($sel);
  while ($row=mysqli_fetch_array($sel)) 
   {
       echo '<tr>
       <td class="col-sm-2">'.$row['name'].'</td>
      <td class="col-sm-2"><a href="#" id="add"  ><img src="../images/add.png"></a> / <a href="#" id="rem"  ><img src="../images/rem.png"></a></td>                   
              </tr>';
              $i++;
              }

1 个答案:

答案 0 :(得分:0)

试试这个,

   $new_array =array(); //array initialzise
 $sel=mysqli_query($db,"SELECT * from srs");
$count=mysqli_num_rows($sel);
  $i=0;
 while ($row=mysqli_fetch_array($sel)) 
  {
        $new_array[]=$row["topic_name"];

   echo '<tr>
   <td class="col-sm-2">'.$row["name"].'</td>
  <td class="col-sm-2"><a href="#" id="add"  ><img src="../images/add.png"></a> / <a href="#" id="rem"  ><img src="../images/rem.png"></a></td>                   
          </tr>';
          $i++;
          }
print_r($new_array);