PDA

View Full Version : Resolved PHP Array



ivankamart
07-07-2018, 05:41 PM
I am trying to use a array to display 6 items instead of doing every single one alone. But I can't figure out how to fetch data from another table within the array.


//first part
$slots = array();
for($i = 1; $i <= 6; $i++) {
$query = mysql_query("SELECT * FROM data1 WHERE user_id = $info[id] AND s = $i");
$slots[$i] = mysql_fetch_assoc($query);
if($slots[$i]) {
} else {
$slots[$i] = "Empty";
}
}

//second part
for($i = 1; $i <= 6; $i++) {
if($slots[$i] != "Empty") {
$pquery[$i] = mysql_query("SELECT * FROM data2 WHERE id = ".$slots[$i]["user_id"]." ");
$slot2 = mysql_fetch_row($pquery[$i]) or die(mysql_error());