Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to pass dynamic array on different pages in php?
    primarykey
    data
    text
    <p>i need to pass array from one page to other pages through button click .actually i fetch each column of database in an array nw i want to pass that array to different pages. i used the session varaible but it is not workng.</p> <p>coding og page2.php in which theses dynamic arrays are get</p> <pre><code>&lt;?php if (isset($_POST['submit'])) { $data_t1 = $_POST['t1']; foreach ($data_t1 as $key =&gt; $value) { $value ; $_POST['t2'][$key]; $_POST['a1'][$key]; $_POST['username'][$key]; } $data_t2 = $_POST['t2']; $data_t3=$_POST['a1']; $data_t4=$_POST['username']; } </code></pre> <p>now i put theses array in databse n fetch them i need to pass these fetch array into next page</p> <pre><code>&lt;?php //database connection $db = new PDO("mysql:host=localhost;dbname=ems",'root',''); //query $sql = "INSERT INTO table1 (c0,c1, c2, c3, c4,) VALUES ('',:c1, :c2, :c3, :c4,) $stmt = $db-&gt;prepare($sql); foreach ($data_t1 as $i =&gt; $value) { $stmt-&gt;execute(array( ':c1'=&gt;$data_t1[$i], ':c2'=&gt;$data_t2[$i], ':c3'=&gt;$data_t3[$i], ':c4'=&gt;$data_t4[$i], &lt;?php include('config.php'); $sa="select * from table1 where timestamp=now()"; $result=mysql_query($sa) or die(mysql_error()); while($row = mysql_fetch_array($result)) { $row['c1']; $row['c2']; $row['c3']; $row['c4']; $m[]=round(($row['c1']/$row['c4']); $n[]=round(($row['c2']/$row['c4']),2); $o[]=round(($row['c3']/$row['c4']),2); $row_count++; } </code></pre> <p>here i call the the fecth array for displayng</p> <pre><code>&lt;?php session_start(); $_SESSION['name'] =$r; $_SESSION['name1'] = $r1; $_SESSION['name2'] = $r2; for($i=0;$i&lt;$row_count;$i++) { // do the exploding, the imploding, the row echoing for each row// ?&gt; &lt;?php echo "&lt;table border='1' align='center'&gt; &lt;tr&gt; &lt;th&gt;Inputs&lt;/th&gt; &lt;th&gt;A&lt;/th&gt; &lt;th&gt;B&lt;/th&gt; &lt;th&gt;C&lt;/th&gt; &lt;/tr&gt;"; echo "Meas1".($i+1); echo "&lt;tr&gt;"; $f=implode($m,','); $r=explode(',',$f); $f1=implode($n,','); $r1=explode(',',$f1); $f2=implode($o,','); $r2=explode(',',$f2); display of data echo "&lt;td&gt;".$r[$i]. "&lt;/td&gt;"; echo "&lt;td&gt;".$r1[$i]. "&lt;/td&gt;"; echo "&lt;td&gt;".$r2[$i]. "&lt;/td&gt;"; } </code></pre> <p>the above all codng on page2.php when i acess these <code>r[],r1[],r2[]</code>on <code>next page</code> i.e. <code>page3.php</code> it disply me empty array</p> <pre><code> page3.php &lt;?php session_start(); $r= $_SESSION['name']; echo $r; var_dump($r); print_r($r); $r1= $_SESSION['name1']; echo $r1; print_r($r1); $r2= $_SESSION['name2']; echo $r2; print_r($r2); ?&gt; </code></pre> <p>plz help for ths</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload