从mysql创建数组并存储在会话中

时间:2012-12-12 06:42:01

标签: php 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)

任何人都可以帮助我吗?我只是对如何做到这一点感到困惑

1 个答案:

答案 0 :(得分: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']
    }