2012-12-12 29 views
-1

我有一個MySQL表是這樣的:創建MySQL和存儲陣列在會議

id | name | value 
------------------ 
1 | logo  | blahblahblah.png 
2 | namestore | blah store 
3 | ip  | 0.0.0.0 

我的問題是如何使用MySQL的獲取該表,然後創建一個PHP調用,例如:

$store->logo (i will get blahblahblah.png) 
$store->namestore (i will get blah store) 

任何人都可以幫助我嗎?我只是很困惑如何做到這一點

+2

你到目前爲止嘗試了什麼。 – Ravi

+0

http://php.net/manual/en/function.mysql-fetch-array.php –

+0

@LearneR,請不要將新的PHP用戶指向不推薦的'mysql_'函數。 – Charles

回答

0
You can use that 



$sql = "select * from your_table_name;"; 

    if (!mysql_query($sql, $conn)) { 
     die('Error: ' . mysql_error()); 
      echo 'error !'; 
    } 

    $result = mysql_query($sql); 

    while ($arr = mysql_fetch_assoc($result)) { 
     //your fetch results are stored in $arr array. you can get values with $arr['column_name'] 
    } 
+0

** Heads up!** PHP的未來版本是*棄用和刪除mysql_'系列函數。現在將是[將示例代碼切換到PDO](http://php.net/book.pdo)或[mysqli](http://php.net/book.mysqli)的好時機。這就是說,這個答案與對鼻子的衝擊一樣有幫助。你能否解釋一下你如何看待這將有助於解決OP的問題? – Charles

+0

謝謝你的擡頭。 – thehilmisu