HI
how i can pass array to a second page

if($report==1){  
?>
<p><img id="myclass123" src='onetwolitre.php?startDate=<?php echo urlencode($startDate)?>
&endDate=<?php echo urlencode($endDate)?>&auto=<?php echo urlencode($auto)?>
&netw=<?php echo urlencode($netw)?>&ser=serialize($ser)?>'/></p>
<?php
}

$ser is array
and in the second page i have this:

......
$ser = unserialize( $ser);
$db=mysql_pconnect("localhost:3306","root","root");
mysql_select_db("campion",$db); 
$endDate2=date( 'Y-m-d', strtotime( $endDate2 ) );
$sql = "SELECT DATE_FORMAT(tran_date,'%d')as datei,unit_serial,sum(unit_qty)*1 as total,account_no,pulse_channel,unit_name  FROM count_transactions
        WHERE DATE(tran_date) BETWEEN '$startDate' AND '$endDate' and unit_serial=$netw and account_no=$auto and unit_name='Litres' and pulse_channel IN($ser)
        GROUP BY DATE(tran_date)";
$result = mysql_query($sql);
$num=mysql_num_rows($result);
$somme=array();
$jour=array();
while($row = mysql_fetch_array($result)){
   $somme[]=$row[total];
   $jour[]=$row[datei];
}
$num=mysql_num_rows($result);
include("../css/phplot.php");
if(preg_match('/(?i)msie [1-8]/',$_SERVER['HTTP_USER_AGENT'])) {
   $graph =& new PHPlot(750,350);
  }
  ......

means pulse_channel must be in the array ...to have a graph..
if there is 3 values in the array then the pulse channel will be 1 2 3
thanks

Just store the array in a session variable like

$_SESSION['whatever'] = $ser;

And then at the top of all the pages that you need to call this one put start_session();

Member Avatar for diafol

You can pass data relatively safely with SESSION. Other ways exist, e.g. DB (but you'd still need a SESSION type id) but this is probably the easiest.

Apart from using session you can pass it by serializing or by imploding and passing it to another page.

  • Either serialize:

    <?php
    $postvalue=array("a","b","c");
    ?>
    <input type="hidden" name="result" value="<?php echo serialize($postvalue); ?>">

There are several ways.Apart from

on receive:

unserialize($_POST['result'])

* or implode:

<?php
$postvalue=array("a","b","c");
?>
<input type="hidden" name="result" value="<?php echo implode(',', $postvalue); ?>">

on receive:

explode(',', $_POST['result'])

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.