Jump to content

NotSureILikePHP

Members
  • Posts

    40
  • Joined

  • Last visited

Everything posted by NotSureILikePHP

  1. That didn't work. It's being called from a different page so I'll include all the code. customers.inc.php $locations = Cust::getLocations($customerID); echo 'locations = '.$locations[0]['location_id']; [/] class.customer.php [code] function getLocations($custID) { $locs = array(); $sql='SELECT DISTINCT l.location_id, l.site_name FROM ' //l.location_id, l.site_name, CONCAT(l.fname, " ", l.lname) AS contactName, email, ' //.'l.phone_number, l.fax_number, c.cust_id, l.address1, l.address2, l.city, ' //.'l.state, l.zip_code, l.contact_number FROM ' .CUST_TABLE.' c ' .' LEFT JOIN '.CUST_LOCATION_TABLE.' l ON (l.cust_id=c.cust_id) ' //.' INNER JOIN '.DEPT_TABLE.' d ON (LOCATE(CONCAT("/", s.dept_id, "/"), d.path) OR d.manager_id=s.staff_id OR LOCATE(CONCAT("/", g.dept_id, "/"), d.path)) ' .' WHERE c.cust_id='.$custID; //.db_input($this->getId()); if (($res=db_query($sql)) && db_num_rows($res)) { while(list($loc)=db_fetch_row($res)) { $columns = array ( 'locID' => $loc['location_id'], 'locName' => $loc['site_name'], ); $locs[] = $columns; } } return $locs; } [/] result is locations = I commented out a lot of that select just to limit it to two columns for now.
  2. It is an empty array I'll try that
  3. I'm trying to add multiple columns to an array. To simplify I'll just say id and name for now. How do I add and call that in the code. I am an asp developer, though it's been a while, so in asp it's something like array[0],["columnName'] Though in php that dot means to concat. Here's my code. $int = 0; if (($res=db_query('SELECT id, name FROM location')) && db_num_rows($res)) { while(list($loc)=db_fetch_row($res)) { $columns = array ( 'locID' => $loc['location_id'], 'locName' => $loc['site_name'], ); array_push($locs[$int], $columns); $int++; } } [/] I'm not sure if that's working or not because I don't know how to get values from the index of the array in php. Most of the code I google seems like an array can only store one value per index.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.