I have a four different tables which have one of the fields as loc1, loc2, loc3, loc4. I am fetching data from database using a procedure from these tables which uses one parameter. I want that every column data when fetched must be saved in a different array i.e loc1 field data in $loc1 array, loc2 field data in $loc2 array and same for other fields. My code is as.
$sql = "call report_card_seven_five_three_one_two('" .id. "')";
$loc1 = array();
$loc2 = array();
$loc3 = array();
$loc4 = array();
if (mysqli_multi_query($connection, $sql)) {
while ($row =mysqli_fetch_row($result))
{
while($row =mysql_fetch_array($result))
{
}
}
mysqli_free_result($result);
while(mysqli_next_result($connection) && mysqli_more_results($connection));
}
Can any one help me on this part.
May be like:
while($row = mysql_fetch_array($result))
{
if(!empty($row['loc1']) || $row['loc1'] != NULL || $row['loc1'] != "")
{
array_push($loc1, $row['loc1']);
}
if(!empty($row['loc2']) || $row['loc2'] != NULL || $row['loc2'] != "")
{
array_push($loc2, $row['loc2']);
}
if(!empty($row['loc3']) || $row['loc3'] != NULL || $row['loc3'] != "")
{
array_push($loc3, $row['loc3']);
}
if(!empty($row['loc4']) || $row['loc4'] != NULL || $row['loc4'] != "")
{
array_push($loc4,$row['loc4']);
}
}