1

This is a follow up on minimize select queries on the same table Mysql. I did not get a full answer on how to extract the individual array values returned by the following query:

$result = mysqli_query("SELECT * FROM u_settings WHERE setting IN
 ('username', 'password','email','tag','active','version','time','warn','dis')");

How do I extract any value I want from the $result array since many rows having the same columns will be returned?

2 Answers 2

1
$result = mysql_query("SELECT * FROM u_settings WHERE setting IN
 ('username', 'password','email','tag','active','version','time','warn','dis')");

while($row = mysql_fetch_assoc($result))
    $settings[$row['setting']] = $row['u_settings'];

print_r($settings);
Sign up to request clarification or add additional context in comments.

Comments

1

Use mysql_fetch_assoc() or mysql_fetch_array() on $result.

Note: I would encourage you to upgrade to MySQLi or PDO, instead of the now deprecated mysql_* functions.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.