2014-10-28 38 views
0

我有一個表與2卡路里,「ID」和「移動」,我想獲得數據庫的所有手機號碼,並插入像這樣的數組$'參數['到'] = array(「mobile_number1」,「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"); 

回答

0

試試這個..

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

坦克的answer.i棒與API發送短信,我需要得到數據庫和插圖的手機號碼數組然後把變量像$ parameters ['to'] = array(「9380009010」,「9380002020」,「930002021」,...);併發送我能做些什麼? – mjmi 2014-10-28 10:34:59

+0

如果此答案對您有用,請投我一票。任何方式。 嘗試設置爲'$ parameters ['to'] = $ numbers;' – 2014-10-28 11:00:20

+0

DB_Connect(); $ result = DB_Select(「SELECT * FROM bs_Content」); $ num_rows = mysqli_num_rows($ result); \t $ numbers []; \t while($ row = mysqli_fetch_assoc($ result)){ \t $ numbers [] = $ row ['mobile']; \t} \t $ parameters ['to'] = $ numbers; -------->不能使用[]讀取第9行的C:\ wamp \ www \ myschools.ir \ index.php – mjmi 2014-10-28 11:23:15