Alright so I am trying to call a function on my index.php that will call a function set on misc.php. The function on misc.php uses a array set on auction-loop.php, but it is returning as if the variable is undefined.
Here's what my auction-loop.php looks like,
<?php
$auctions = array();
$row = array();
$sqlquery = "SELECT * FROM auctions";
if ($result = $db->query($sqlquery)) {
while ($row = $result->fetch_assoc()) {
$auctions[$row['id']]['id'] = $row['id'];
$auctions[$row['id']]['title'] = $row['title'];
$auctions[$row['id']]['featured_image'] = $row['featured_image'];
$auctions[$row['id']]['description'] = $row['description'];
$auctions[$row['id']]['date'] = $row['date'];
$auctions[$row['id']]['location'] = $row['location'];
$auctions[$row['id']]['highlights'] = $row['highlights'];
$auctions[$row['id']]['catagories'] = $row['catagories'];
$auctions[$row['id']]['notes'] = $row['notes'];
$auctions[$row['id']]['terms'] = $row['terms'];
$auctions[$row['id']]['contact'] = $row['contact'];
}
}
?>
Here's the misc.php,
<?php
function auction_title($auction_id){
echo $auctions[$auction_id]['title'];
}
?>
And finally, the function being called on index.php,
include_once ('parts/connections/connection.php');
include_once ('parts/staticfiles/auction-loop.php');
include_once ('parts/staticfiles/misc.php');
<?php auction_title(1); ?>
With all of that, it is spitting out the error,
Notice: Undefined variable: auctions in D:\xampp\htdocs\parts\staticfiles\misc.php on line 8
Is the array being set on auction-loop.php not making it to misc. Thanks in advance! :)