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
54
Other forums
date("now") prints out wrong date ?
Hi Guys
Anyone know why and how I can fix it ?
Form help: Syntax & Logic
Hello again all,
I'm working on a form and ran into a wall (again) and can't seem to think th
Checkbox info wont include in Mailto
Hey, im new to php.
Basically I have made a form to request which type of job(s) are needed, whic
Help with lottery style system?
I'm working on a currency system for forums and it is going to have a type of lottery system built i
Redirecting Admin
In my members table, I have a field called "perm" and it's set to zero for all members. Ho
Problems with array
This code is the last lines in an upload script that uploads 4 images at the same time and writes th
Parse error: parse error in C:wampwwwlogspagesmembers.php on line 16
I dont see the problem with this, I always get Parse error: parse error in C:wampwwwlogspagesme
CE 7.1 and External GIS integration
Hi All,
We want to develop an application on CE 7.1 which uses GIS features from an exter
tell csv import script to ignore blank rows?
Hi i have the below script but i get an error if a row is blank ie a return in the csv file at the e
curl javascript problem
Hi Experts.
I'm new curl and wanna to get some info from this http://www.amadeus.net/
when