William The Dev William The Dev - 6 months ago 10
SQL Question

Extracting values from SELECT WHERE IN query MySQL

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?

Answer
$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);
Comments