LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-10-2007, 02:14 AM   #1
secretlydead
Member
 
Registered: Sep 2003
Location: Qingdao, China
Distribution: mandriva, slack, red flag
Posts: 249

Rep: Reputation: 31
php array into many pictures


I'm working on a script that generates graphs for a marketing report.

It takes the volume of cargo we send to different ports in the US and analyzes.


The problem is around here:

for ($j = 0; $j < 2 /*$destnum_result*/; $j++)
{
$destrow = mysql_fetch_array($destresult);
$dest = $destrow['dest'];

$_SESSION['dest'] = $dest;

echo "
<tr>
<td>".$_SESSION['dest']."<img src='chart-pie-export+seaair-ro-local-variableport.php'></td>
</tr>
";
unset($SESSION['dest'],$dest);
}

echo "</table>"


This is the last attempt before I finally gave up and ran to this forum.

The ports ($dest) list in order of volume. 1 - NYC, 2 - MIA (Miami)...

The problem is with the script I am using to generate the graph, a very nice script called PLChart. Basically, this works if I use $j < 1, then it only displays on graph, with the correct values for NYC.

However, if I say $j < 2 or higher, it shows to graphs, but each of the graphs is the same and they are both (in this case) MIA (Miami). (If we did 3, all three graphs would be the same, and they would all be the port with the third greatest volume, etc...)

Anyone have any idea how to make this work or why this will never ever work? Thanks.
 
Old 10-10-2007, 07:12 AM   #2
buggabill
Member
 
Registered: Jun 2006
Location: Maine, USA
Distribution: Kubuntu 8.10/Debian Lenny
Posts: 30

Rep: Reputation: 15
Trying to unset a $_SESSION variable from within a function can be problematic. Take a look at the help page for unset on php.net. This little snippet came from there and may help you...I hope.


Quote:
Here is another way to make 'unset' work with session variables from within a function :

PHP Code:
<?php
function unsetSessionVariable ($sessionVariableName) {
   unset(
$GLOBALS[_SESSION][$sessionVariableName]);
}
?>
Also, don't know if it is a typo, but in your post you have

PHP Code:
unset($SESSION['dest'],$dest); 
Me thinks:

PHP Code:
unset($_SESSION['dest'],$dest); 
would work a bit better. From what I gather in the help, the only way to unset a global from within a function is if register_globals is 'ON'.

Good luck!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP - Dynamically listing pictures - but only a certain # per page? ziphem Programming 1 06-24-2007 05:52 AM
Can't use my PHP array. rblampain Programming 4 06-23-2006 07:19 AM
php: array with functions ldp Programming 7 09-22-2004 04:55 PM
PHP array help? HappyDude Programming 1 10-13-2003 06:48 PM
php array gui10 Programming 2 03-26-2002 02:07 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration