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
54
Other forums
Operating System
How in PHP or other language can I detect Operating system, ie Windows XP Home, Windows 7 Ultimate,
Adding Different Numbers From MySQL
Basically I have a mysql database with a couple prices as the following:
9.99
9.99
9.99
Need help-Error istream header declaration
Hi Everyone ,
I am having issue with istream declaration. I am new to C programming.
can a
Help on query replacing the date
Hi Pals,
i want to replace the current date in a column to some value say C or D or any n
extract content from a website
i have written a code that will grab the content from the index page..
i would like to know how c
with clause
hi all, i have a big query that usually access the same table more than once. for example, i have s
if php cookie set, show code...
Hi all.. I need to figure out this little snippet right quick.. seems like it should be easy enough
ASP.NET 2.0 - Enter Key - Default Submit Button
Hi,One of the most annoying things in developing web pages is handling the "Enter key" for form subm
extract a file from zip file
hi,
i know how to unzip a zip file in php, but is there a way to just extract a certain file only
WELCOME SCREEN
first of all let me tell you what does my script do,
it´s a very simple query to show a e