Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 30th, 2004, 02:17 AM
Authorized User
 
Join Date: Jan 2004
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default pass array from a page to page

how to pass array from a page to page???

this is my code snippet on page 1:
Code:
$query5=query("SELECT komponen,jumlah FROM tempkomponen order by komponen", $link, __LINE__,__FILE__);

$ParameterCounter=1;
while ($periksa1 = mysql_fetch_row($query5))
{   
$alat[]=$periksa1[0];
$jum[]=$perkara1[1];

$ParameterCounter = $ParameterCounter + 1;
}




and this is at ppage 2:
Code:
include("phpchartdir.php");


#The data for the pie chart
$data = $_GET(array["$alat"]);
//$data = $data;

#The labels for the pie chart
$labels=$_GET(array["$jum"]);
//$labels = $labels;

#Create a PieChart object of size 450 x 240 pixels
$c = new PieChart(450, 240);

#Set the center of the pie at (150, 100) and the radius to 80 pixels
$c->setPieSize(150, 100, 80);

#Add a title at the bottom of the chart using Arial Bold Italic font
$c->addTitle2(Bottom, "Project Cost Breakdown", "arialbi.ttf");

#Draw the pie in 3D
$c->set3D();

#add a legend box where the top left corner is at (330, 40)
$c->addLegend(330, 40);

#modify the label format for the sectors to $nnnK (pp.pp%)
$c->setLabelFormat("{label} \${value}K\n({percent}%)");

#Set the pie data and the pie labels
$c->setData($data, $labels);

#Explode the 1st sector (index = 0)
$c->setExplode(0);

#output the chart
header("Content-type: image/png");
print($c->makeChart2(PNG));



but i think the passing process seems failed...
what is the correct way??

 
Old January 30th, 2004, 02:30 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 101
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Moharo
Default

hey

there few ways you can walk around this, the most reasonable one would be using session array. so basically create an array, populate it with some stuff, whatever it is... just check the code...

first_page.php

<?php

session_start();
$my_array = array("anything','goes','in','here');
$_SESSION["my_array"] = $my_array;

?>

second_page.php

<?php

session_start();
//now you can just recall to the array you created in the first
//page by doing this

print_r($_SESSION["my_array"]);

?>

that's how i would do it... peace :D


the genuine genius
 
Old January 30th, 2004, 03:29 PM
Authorized User
 
Join Date: Jan 2004
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

errrrr...
but how to use that in my coding??
i dont know which one to alter...
actually all the above ij just a copy and paste code...
can u help me fix my coding???

 
Old January 30th, 2004, 03:33 PM
Authorized User
 
Join Date: Jan 2004
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i try to use the session things...
but it shows me wrong amount for array[2]..everytime i refresh the page the amount is increasing to certain amount...
why???

this is at first page:
Code:
$query5=query("SELECT * FROM tempkomponen order by komponen", $link, __LINE__,__FILE__);

//$ParameterCounter=1;
while ($periksa1 = mysql_fetch_row($query5))
{    
$alat[]=array($periksa1[1]);
$jum[]=array($periksa1[2]);
} 
session_start();


$_SESSION["firstquarter"] = $alat;


$_SESSION["firstquarter2"]  =$jum;


//$ParameterCounter++;
and this is at second page:

Code:
session_start();
include("phpchartdir.php");


#The data for the pie chart
$data = $_SESSION["firstquarter"];



#The labels for the pie chart
$labels= $_SESSION["firstquarter2"];
whats wrong with my code??





Similar Threads
Thread Thread Starter Forum Replies Last Post
pass the value of one page to another.... rocksbhavesh BOOK: Beginning ASP.NET 1.0 1 March 14th, 2007 06:36 AM
Posting String Array From one page to another page Samatha ASP.NET 1.0 and 1.1 Professional 1 December 6th, 2006 03:54 AM
How to pass variables from Aspx page to Asp Page jayaraj Classic ASP Basics 2 May 23rd, 2004 06:56 AM
How to pass the variables in Aspx page to Asp Page jayaraj ASP.NET 1.0 and 1.1 Basics 3 May 23rd, 2004 06:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.