2012-12-13 88 views
0
//getting values from dataBase 
$sql = "SELECT `email` , `password` FROM `user_inf`"; 
// Execute query 
$result = mysql_query($sql,$con); 
$email; 
$pass; 

while($row = mysql_fetch_array($result)) 
{ 
$email = $row['email']; 
$pass = $row['password']; 
} 



// create a dummy array 
$doc = array (
1 => array ("Email", "Password") 
    array ($email, $pass), 
); 

我需要填寫該陣列的「doc」我從數據庫中獲取和使用,雖然loop.I希望把所有的值數組中獲取動態.The值添加到一個數組動態

回答

2

只要這樣做:

$result = mysql_query("SELECT `email` , `password` FROM `user_inf`", $con); 
$doc = array(array("Email", "Password")); 
while($row = mysql_fetch_array($result)) { 
    $doc[] = array($row['email'], $row['password']); 
} 
+1

我喜歡沉默downvoters。爲什麼? –

+0

感謝Eugene Manuilov非常感謝。爲什麼一些人投下了你的答案呢? – user1635431