Jump to content

problem with array and json_encode, decode


felito

Recommended Posts

hi

 

i have this code:

 

 

//sql
	$sql -> bind_param('s',$offer);
	$sql -> execute();
	$sql -> bind_result($oferta, $cargo, $conteudo, $tipo_oferta, $local);

	$arr = array();
	while ($sql -> fetch()) {
		$arr[] = array($oferta, $cargo, $conteudo, $tipo_oferta, $local);

	};
	return $arr;

 

then i make this in ajax (jquery)

  data: 'all=<?php echo json_encode($arr); ?>',

 

and in other page i make:

 

$editar = $_POST['all'];

$e = json_decode($editar, true);

echo $e[0][0];

 

the problem is: if i only do :

 

$arr[] = array($oferta);

this  echo $e[0][0]; outputs: designer (is the value of $oferta)

 

but if i do

$arr[] = array($oferta, $cargo, $conteudo, $tipo_oferta, $local);

echo $e[0][0]; simply doesn't show anything.

 

the question is why ? and how can be solved?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.