Jump to content

rishe

Members
  • Posts

    3
  • Joined

  • Last visited

rishe's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. rishe

    looping arraylist

    hi all, i am fetching the data from database in array as Array ( [0] => Array ( [latitude] => 3397019 [longitude] => 8541652 ) [1] => Array ( [latitude] => 3497019 [longitude] => 8641652 ) [2] => Array ( [latitude] => 3597019 [longitude] => 8741652 ) ) now how to convert the above as Array ( [0] =>3397019, 8541652 ) [1] =>3497019,8641652 ) [2] => 3597019, 8741652 ) ) my code for fetching the records is $sql = "SELECT * FROM atm "; $array = array(); $result = mysql_query($sql); if (! $result){ throw new My_Db_Exception('Database error: ' . mysql_error()); } while($row = mysql_fetch_assoc($result)){ $latlon[] = $row; } print_r($latlon);
  2. i have tried with implode() function, but i am getting error as "Warning: implode(): Invalid arguments". My code is $dept= "ATM"; $sql = "SELECT `layer1`,`layer2`,`layer3` FROM `dept_desc` where `departments` = '$dept'"; //Run the query $result = mysql_query($sql); if (! $result){ throw new My_Db_Exception('Database error: ' . mysql_error()); } while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $layers= "['{$row['layer1']}' ,". "'{$row['layer2']}', ". "'{$row['layer3']}' ]". "<br>"; }
  3. i am fetching data from database. and storing that data in the array. the result is Array ( [0] => Array ( [workspace] => cite [layer1] => layer [layer2] => atm layer1 [layer3] => atm layer2 ) ) how to convert the above array as string. so that the result should be like this cite,layer , atm layer1 ,atm layer2 my code is $dept= "ATM"; //Create the query $sql = "SELECT `workspace`,`layer1`,`layer2`,`layer3` FROM `dept_desc` where `departments` = '$dept'"; //Run the query $result = mysql_query($sql); if (! $result){ throw new My_Db_Exception('Database error: ' . mysql_error()); } $arr = array(); while($row = mysql_fetch_assoc($result)) { $arr[] = $row; } print_r ($arr);
×
×
  • Create New...