Values disappear from my array :( HELP!


Posted on 16th Feb 2014 07:03 pm by admin

hey all, I have a lil mysql/php/apache script that queries a database
and pulls put 5 integers.

These 5 integers are then displayed in an HTML table
Did you know?Explore Trending and Topic pages for more stories like this.

Code: [Select]<?php
$i=0;
global $Val_Store;
while ($i < $num) {

$f1=mysql_result($result,$i,"Changes");
$f2=mysql_result($result,$i,"Disposition");

?>

<tr>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td>

</tr>

<?php

$Val_Store[i] = $f1;

$i++;
echo $Val_Store[i] . "-> Val_STORE" . $i . "<br />";
}



This is just a snippet.
But what is happening is:
A while loop is going through the rows of results obtained from the query, placing the values in temporary variables f1 and f2 (f1 are my integers of interest), and using f1 and f2 to fill the HTML table like this:
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td>

BUT what i am also doing is storing the temporary values in f1 in the array $Val_Store
Code: [Select]$Val_Store[i] = $f1;
$i++;

And then printing them ....

Code: [Select]echo $Val_Store[i] . "-> Val_STORE" . $i . "<br />";



Leaving me with
84-> Val_STORE1
114-> Val_STORE2
99-> Val_STORE3
77-> Val_STORE4
5-> Val_STORE5


WHICH IS SUPER!


BUT if i try executing the following code in other sections of my script....

Code: [Select]<?
echo "DEBUG " . $Val_Store[2] . " DEBUG";
?>

...the arrays appears to be empty. Surely it should have spat out element number 2!!

Output:
DEBUG DEBUG
^



Can anyone help me keep my array elements??

Many Thanks
No comments posted yet

Your Answer:

Login to answer
151 Like 54 Dislike
Previous forums Next forums
Other forums

convert PHP array to Javascript array
I have a page that gets a request sent from AJAX, and I am trying to convert a PHP array to a javasc

how to load a Sys file with system load and call images?
normally you need register the module as a service with CreateService, and start the service

Show specific day of the week
I have been racking my brain trying to get this function to work properly and it is doing so for eve

(sub)screen resize modification doesn't work after ECC 6 EhP 4 installation
Hello,

We have previously extended the size of the custom data tab on PO transaction ME23

How To Make More Than One Redirection with PHP on the same page?
Hey im trying to do a direction page where it open differently link direction pages every time som

Issues: PHP Forms -Clearing
I've tried looking online before actually asking for help, but I've been looking for about the past

Php mysql - select?
Hi i have this code:
Code: $iteminfo = mysql_query("SELECT desc FROM wc_items WHERE itemid =

Something like an INI editor or a DelimitedText-Editor
Hi all,

Am very, very, very new to PHP and not sure if I should be posting this to a Javascri

Wierd echo error?
Hi, i got the most wierd php error ever and i don't know why..
Code: echo "<t

Problem with Subscreen
Dear Experts ,
I am facing a problem with the subscreens. My senario is as follows :

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash