简体   繁体   中英

select multiple rows different value from same table

This is my table " OPTIONS "

在此处输入图片说明

Here i need to get site_logo,facebook and twitter values only from single mysql query.

Thank you

As simple as it is..

SELECT id,option_key,option_value FROM options

or

SELECT * FROM options

You can do like this Using PDO

    $dbh = new PDO("mysql:dbname=pages;host=localhost", "username", "password");
    $sth = $dbh->prepare('SELECT id,option_key,option_value FROM options');
    $sth->execute();

尝试这个

SELECT * FROM TABLENAME ;

SELECT * FROM options` then, in the PHP:

while ($row=MySQLi_fetch_assoc($result))
{
    echo "<option value=\"".htmlspecialchars($row['option_value'])."\">".
    htmlspecialchars($row['option_key'])."</option>";
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM