how i can pass array to a second page

<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>

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

$ser = unserialize( $ser);
$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);
while($row = mysql_fetch_array($result)){
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

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

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:

    <input type="hidden" name="result" value="<?php echo serialize($postvalue); ?>">

There are several ways.Apart from

on receive:


* or implode:

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

on receive:

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