I pass data from database in array form, then I want to show this array in php -


how use $objects in function?
pass data database in array form, want show array in php page, it's printing word "array".

i want print in format--> [ ['trident','internet explorer 4.0','win 95+','4','x'], ['trident','internet explorer 5.0','win 95+','5','c'], ['trident','internet explorer 5.5','win 95+','5.5','a'] ] code:

    function showing_daily_basket(){      $connect_mysql= @mysql_connect($server,$username,$passwor) or die ("connection failed!");     $mysql_db=mysql_select_db("gp15",$connect_mysql) or die ("could not connect database");     $query = "select * basket_daily_work";     $result=mysql_query($query) or die("query failed : ".mysql_error());             $objects= array();     while($rows=mysql_fetch_array($result))     {                     $objects[]= $rows;     }     exit($objects);  } 

and if paste var_dump($objects);' after while loop result blockquote

the result

after edit it's return nothing

$connect_mysql= @mysql_connect($server,$username,$passwor) or die ("connection failed!");  $mysql_db=mysql_select_db("gp15",$connect_mysql) or die ("could not connect database");  $query = "select * basket_daily_work";  $result=mysql_query($query) or die("query failed : ".mysql_error());              $objects= array();      while($rows=mysql_fetch_array($result))      {                      $objects[]= $rows;      }  	var_dump($objects);  $data_set = "[";  $count_rows = count($objects);  $count = 1;  foreach($objects $object){      $data_set .= "['". $object['basketid'] ."', '". $object['date'] ."', '". $object['time'] ."', '". $object['flag'] ."']";      if($count != $count_rows){          $data_set .= ",";          $count++;      }  }  $data_set .= "]";  echo $data_set;  	

there array within $objects each row returned in query. can loop through these , results.

foreach($objects $object){     echo $object['column_name']; } 

this code echo out value of column name specified each row returned.

a way see structure of $objects before doing results is

print "<pre>"; var_dump($objects); 

edit - try this

$data_set = "[";     $count_rows = count($objects);     $count = 1;      foreach($objects $object){         $data_set .= "['". $object['basketid'] ."', '". $object['date'] ."', '". $object['time'] ."', '". $object['flag'] ."']";          if($count != $count_rows){             $data_set .= ",";             $count++;         }     }      $data_set .= "]"; 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -