I have an array containing about 400 10-20 character, single string number items. I want to query my database from this array in the most efficient way (on server load and load time) possible. Here is what I have currently but it takes about 4-6 seconds to load the page.
foreach(unserialize(mysqli_fetch_array(mysqli_query($database, "SELECT `array` FROM `users` WHERE `id` ='00000001'"))[0]) as $value) {
$friend_id = mysqli_fetch_array(mysqli_query($database, "SELECT `id` FROM `users` WHERE `id` ='".$value."'"))[0];
if(!empty($friend_id)){
echo mysqli_fetch_array(mysqli_query($database, "SELECT 'username' FROM `users` WHERE `id` ='".$value."'"))[0] . "<br />";
}
}