如何将数据库插入的移动号码提取添加到数组中

时间:2014-10-28 09:32:51

标签: arrays

我有一张有2个卡路里的桌子," id"和#34;移动",我想获得所有移动号码的数据库并插入一个数组,如$ parameters [' to'] = array(" mobile_number1",& #34; mobile_number2"," mobile_number3",...," mobile_number last in database"); 如何为我的请求更改此代码:

  DB_Connect(); // connect function
  $result = DB_Select("SELECT * FROM bs_Content");
  $num_rows = mysqli_num_rows($result);
  while($row = mysqli_fetch_assoc($result)){
     $i = $row['id'];
     $id[$i] = $row['mobile'];
  }
  for($i=1 ; $i<=$num_rows ; $i++){
     print_r($id[$i]);  
  }
  DB_Disconnect();

 // total i wand like array("9380009010","9380002020","930002021");

1 个答案:

答案 0 :(得分:0)

试试这个..

$numbers[];
  while($row = mysqli_fetch_assoc($result)){
     $numbers[] = $row['mobile'];
  }