Hello everyone! I have an app that uses a for loop to go through an array and it selects all the values from my MySQL database and returns the values. I can't imagine that this is the best approach. My code kinda looks like this:
Cna anyone offer up a better, more efficient way of going about this? Thanks in advanced!!
Code:
$array = array('blah', 'bleep', 'bloop');
$password = 'same_value_for_each_item_in_the_array';
$name = 'same_value_for_each_item_in_the_array';
$userArray = array();
$passArray = array();
$nameArray = array();
for($i=0; $i<count($array); $i++)
{
$result = mysql_query("SELECT * FROM `table` WHERE `user`='$array[$i]' AND `password`='$password ' AND `name`='$name ' ORDER BY `date` DESC LIMIT 60");
if($result) {
while ($row = mysql_fetch_object($result)) {
$userArray[] = $row->user;
$nameArray[] = $row->name;
$passArray[] = $row->password;
}
}
}
Comment