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

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

Anti Spam Code Problems
Ok where do i start? Probably by telling you I have very little working knowledge of PHP and that I

How to give the privillege for triggers?
Hi,

How to give the privillage for triggers to particular user?

Please let me

Unable to display contents in Second Drop Down Box
Hi All,

What I am trying to do is 2 dependent drop down boxes and when user selects su

Not showing whole name with mail () script
I sent up a simple mail form with the PHP mail() script. One problem is when it sends an email with

Wierd if else problem
Hi guys,

this probably aint wierd for you, but it seems like php is playin up to me. may b i

void* and sizeof()
Hi,

Using void* and sizeof is it possible to get the value of the object ?

I understan

How to have a log of all the status a VIM document had been ?
Hi guys,

I’m using SAP Invoice Management plugin and the /OPT/VIM_ANALYTICS transa

php mailer
How can i send a mail to large no, say 50,000 reciepients using [color=#0000FF]php mailer[/color]

How to Detect it is public_html or httpdocs?
How to check whether it is cPanel or Plesk?

If it found public_html perform <?php incl

private constructor
Hello,

Can we create a constructor as private? If yes, what is the use of it? If no, why can'

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