geudrik Posted September 1, 2009 Share Posted September 1, 2009 I'm guessing that I have my method wrong here somewhere along the lines... Anyone willing to point me in the right direction as to where I'm going wrong with my arrays? <?php @define('IN_SPAAZZ', true); include('config.php'); database(1); // Make sure we arent trying to execute anything without being called properly... if(!isset($_GET['id'])) { die("This page must not be accessed directly..."); } // This ID is the ID for the given solar system..... $systemid = $_GET['id']; // SQL for pulling station information // stationTypeID used in reference to staOpperations // to get services at station // Variable for stationTypeID - $stTypeID // $stTypeID then references staStationTypes $get_stations = "SELECT officeRentalCost, operationID, stationTypeID, corporationID, stationName, reprocessingEfficiency, reprocessingStationsTake FROM staStations WHERE solarSystemID = '$systemid' ORDER BY stationName"; // SQL for pulling solar system info... ehehehee $get_sysinfo = "SELECT itemID, itemName FROM eveNames WHERE itemID = '$systemid'"; // Set queried variables... $stations = mysql_query($get_stations); $system = mysql_query($get_sysinfo); //Master Array $sysInfo = array(); // Declair the variable to hold each array, containing all datumz... // Child Array - Holds station info - NOT SERVICES $info = array(); //Child Array - Holds operationservice ID's... $svcIDs = array(); // Child array - holds station services $staSvcs = array(); while ($rowsta = mysql_fetch_assoc($stations)) { $rentalCost = $rowsta['officeRentalCost']." ISK per 30 Days<br />"; $staTypeID = $rowsta['stationTypeID']."<br />"; $corpID = $rowsta['corporationID']."<br />"; $staName = $rowsta['stationName']."<br />"; $repoEffic = $rowsta['reprocessingEfficiency'] * 100 ."%<br />"; $repoStaTake = $rowsta['reprocessingStationsTake'] * 100 ."%<br /><br />"; // Need Op ID to reference staOpperationServices (opID -> ServiceID) then from staServices (ServiceID -> ServiceName) $opperationID = $rowsta['opperationID']; // Push data into the array $info in the following order... array_push($info, array("$staName", "$corpID", "$staTypeID", "$rentalCost" , "$repoEffic", "$repoStaTake", "$opperationID")); } //array_push($sysInfo, $info); foreach($info as $key) { // SQL for grabbing service ID's based on $key $keyql = "SELECT serviceID FROM staOperationServices WHERE operationID = '$key'"; $keyqlres = mysql_query($keyql); while($rowz = mysql_fetch_assoc($keyqlres)) { $staSvcIds = $rowz['serviceID']; array_push($svcIDs, "$staSvcIds"); } } foreach($svcIDs as $key) { $svcSql = "SELECT serviceName FROM staServices WHERE serviceID = '$key'"; $svcNameRes = mysql_query($svcSql); while($svRow = mysql_fetch_assoc($svcNameRes)) { $svcs = $svRow['serviceName']; array_push($staSvcs, array("$svcs")); } //array_push($sysInfo, $staSvcs); } // Push two child arrays (Services and Sta Info) into master array... Ignore ID array... //array_push($sysInfo, $info); print_r($info); //print_r($staSvcs); database(0); ?> Edit: Right. I don't get errors here, just... when I print_r on any of my arrays, they're all empty. Quote Link to comment https://forums.phpfreaks.com/topic/172645-solved-empty-arrays/ Share on other sites More sharing options...
MadTechie Posted September 1, 2009 Share Posted September 1, 2009 if your first query fails all you arrays will be empty, double check it also is error reporting on ? try $stations = mysql_query($get_stations) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/172645-solved-empty-arrays/#findComment-910061 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.