0

hi i got the dynamic arry to get on one form i need to pass that array to other forms as well.In that i perfomed some computation as well that i show below i need to pass $data_t1 as it contain the dynamic array show can i pass ths to other form.

page1.php

    <?php

        for ($i = 1; $i <= $de; $i++) {
        ?>
        <tr>

            <td>
                <select id="in4-<?php echo $i; ?>" name="t1[<?php echo $i; ?>]" onclick="getText3(<?php echo $i; ?>)" onchange="getText39(<?php echo $i; ?>)" onmouseout="getText89(<?php echo $i; ?>)">
                    <option value="0">0</option>
                    <option value="12">12</option>
                    <option value="18">18</option>
                    <option value="24">24</option>
                    <option value="75">75</option>
                </select>
            </td>
            <td>
                <input type="text" name="t2[<?php echo $i; ?>]" id="in1-<?php echo $i; ?>" onblur="getText3(<?php echo $i; ?>)" onchange="getText39(<?php echo $i; ?>)" onmouseout="getText89(<?php echo $i; ?>)"/>
            </td>
            <td>
                <select name="a1[<?php echo $i; ?>]" id="in2-<?php echo $i; ?>" onclick="getText3(<?php echo $i; ?>)"onchange="getText39(<?php echo $i; ?>)" onmouseout="getText89(<?php echo $i; ?>)" >
                    <option value="0">0</option>
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                    <option value="4">4</option>
                    <option value="5">5</option>
                    <option value="6">6</option>
                    <option value="7">7</option>
                    <option value="8">8</option>
                </select>
            </td>
            <td>
                <input type="text" id="in3-<?php echo $i; ?>" name="username[<?php echo $i; ?>]" readonly="readonly" />
            </td>
<?php }?>
        </table>

    <input type="submit" name="submit" />



coding of acessing array from page1.php

<?php

if (isset($_POST['submit'])) {

    $data_t1 = $_POST['t1'];


    foreach ($data_t1 as $key => $value) {

        $value ;
       $_POST['t2'][$key];
    $_POST['a1'][$key];
      $_POST['username'][$key]; 



    }
      $data_t2 = $_POST['t2'];
      $data_t3=$_POST['a1'];
      $data_t4=$_POST['username'];

}

?>
  <?php
  //database connection
$db = new PDO("mysql:host=localhost;dbname=ems",'root','');
//query
$sql = "INSERT INTO table1 (c0,c1, c2, c3, c4 ,c13) VALUES ('',:c1, :c2, :c3, :c4, '$d')";
$stmt = $db->prepare($sql);
foreach ($data_t1 as $i => $value) {
    $stmt->execute(array(
       ':c1'=>$data_t1[$i],
       ':c2'=>$data_t2[$i],
       ':c3'=>$data_t3[$i],
       ':c4'=>$data_t4[$i],
    ));
} ?>
<?php
include('config.php');
$sa="select * from table1 where timestamp=now()";
$result=mysql_query($sa) or die(mysql_error());
$th=-2;
$xa=1;
$xb=2;
$xc=2;
echo "<table border='1'>
<tr>

</tr>";
$row_count=0;

while($row = mysql_fetch_array($result)) 
{ 
     $row['c1'];
   $row['c2'];
     $row['c3'];
     $row['c4'];

    $a[]=$row['c1'];
        $b[]=$row['c2'];
            $c[]=$row['c3'];
            $d[]=$row['c4'];

            //tube lights//
                $m[]=round(($row['c1']/$row['c4']),2);
                $n[]=round(($row['c2']/$row['c4']),2);
                $o[]=round(($row['c3']/$row['c4']),2);

                //ccr model technique//
                //tube lights//
                $m1[]=abs(round((((($row['c1'])*($th)+($row['c1']*$xa)+($row['c5']*$xb)+($row['c9']*$xc))+1)/2),2));
                $n1[]=abs(round((((($row['c2'])*($th)+($row['c2']*$xa)+($row['c6']*$xb)+($row['c10']*$xc))+1)/2),2));
                $o1[]=abs(round((((($row['c3'])*($th)+($row['c3']*$xa)+($row['c7']*$xb)+($row['c11']*$xc))+1)/2),2));



                $row_count++;

}

 //optimial values//
$fa=implode($a,',');
$fa1=explode(',',$fa);
$fb=implode($b,',');
$fb1=explode(',',$fb);
$fcc=implode($c,',');
$fcc1=explode(',',$fcc);
$fe=implode($e,',');
$fe1=explode(',',$fe);
$ff=implode($f,',');


    //for efficeiency frointer//

for($i=0;$i<$row_count;$i++) 
{ // do the exploding, the imploding, the row echoing for each row// 
echo "<table border='1' align='center'>
<tr>
<th>Inputs</th>
<th>A</th>
<th>B</th>
<th>C</th>
</tr>";
echo "Measuring1".($i+1);
  echo "<tr>";
  //tube lights//
     $f=implode($m,',');
     $r=explode(',',$f);

     $f1=implode($n,',');
     $r1=explode(',',$f1);

     $f2=implode($o,',');
     $r2=explode(',',$f2);


echo "<td>" ."W"</td>";
echo "<td>".$r[$i]. "</td>";
echo "</tr>"; 
echo  "<td>" ."No. "</td>";
echo "<td>".$r1[$i]. "</td>";
;
 echo "</tr>"; 
echo  "<td>" ."Dur "."</td>";
echo "<td>".$r2[$i]. "</td>";
echo "</tr>"; 

echo  "</table>";
}
for($i=0;$i<$row_count;$i++) 
{
echo "<table border='1' align='center'>
<tr>
<th>Inputs</th>
<th>ccr</th>
<th>ccr</th>
<th>Ccr</th>
</tr>";
  echo "<tr>";
  echo "Measuring 2".($i+1);  
      //tube lights//
     $fc=implode($m1,',');
     $rc=explode(',',$fc);

     $fc1=implode($n1,',');
     $rc1=explode(',',$fc1);

     $fc2=implode($o1,',');
     $rc2=explode(',',$fc2);

     //ccr model technique// 
 echo "<td>" ."Wa ". "</td>";
echo "<td>".$rc[$i]. "</td>";
echo "</tr>"; 
echo  "<td>" ."n ". "</td>";
echo "<td>".$rc1[$i]. "</td>";
echo "</tr>"; 
echo  "<td>" ."Dur "."</td>";
echo "<td>".$rc2[$i]. "</td>";
echo  "</table>";
}
?>

<?php
for($i=0;$i<$row_count;$i++) 
{
echo "<table border='1' align='center'>
<tr>
<th>Inputs</th>
<th>A</th>
<th>B</th>
<th>C</th>
</tr>";
 echo "<tr>";
  echo " Optimial values Of Room ".($i+1);
  //voltage of appliances//
   echo "<td>" ."W". "</td>";
if($fa1<=$rc)
{

echo "<td>". $fa1[$i]."</td>";
}
else
{

echo "<td>". $rc[$i]."</td>";
}
  echo "<tr>";
      echo "<td>" ."Du". "</td>";
if($fcc1<=$rc2)
{
echo "<td>". $fcc1[$i]. "</td>";
}
else
{
echo "<td>". $rc2[$i]. "</td>";
}
echo "</tr>";
 echo "<tr>";
    echo "<td>" ."Co". "</td>";
if($fa1<=$rc && $fb1<=$rc1 && $fcc1<=$rc2 )
{

 $gk[]=round(((($fa1[$i]*$fb1[$i]*$fcc1[$i])*30)/1000),2);
 echo  "<td>" . $gk[$i]. "</td>";
 }
else
{
$gk1[]=round(((($rc[$i]*$rc1[$i]*$rc2[$i])*30)/1000),2);
 echo  "<td>" . $gk1[$i]. "</td>";
}

?>

plz help me for ths.

3
  • which type of value you want to send.form already send value to action perform page.you can also send though input type hidden.i need little chat to understand your problem. Commented Jun 1, 2013 at 11:22
  • sir i actually want the page2.php data on page3.php n page4.php.same table same data Commented Jun 1, 2013 at 13:30
  • page1.php remain the same m one thing i want to convey you that i want the data through button click or through link Commented Jun 1, 2013 at 14:25

2 Answers 2

2

I would like to comment on the previous answer by @mightyuhu, but I dont have the rep yet, so I´ll try it this way:

Just from reading your question and not the complete a little confusing code, i would say his approach is perfectly correct: sessions.
But since you apparently dont know how to handle them - here a very short how-to:

Call session_start(); on any site you want to access the shared data on - but call it before any output was made, before any echo or print or empty line or html-code outside the php-tags. After that you can access/set/modify your session data via $data = $_SESSION['my_variable_name']; and $_SESSION['my_variable_name'] = $new_data;.
If you want to remove the data afterwards call unset($_SESSION['my_variable_name']);.

Hope that helps :)

Sign up to request clarification or add additional context in comments.

Comments

1

Take a look at SESSIONs , you can store temporary Session Data in there.

3 Comments

no sir it coulb be any way without session if feell difficulty while using session n dont know the exact place to use n place the session in the code
@user2421659 Sessions, APC, file on disk, shared memory, POST or GET, inter processes communication, avoid page change with Ajax, ... Sessions is probably the easiest and more natural..
how can i put session on page3.php? i want to acess the data as well as all the tables on page3.php from page2.php

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.