lol its that easy... i actually had something v similar to that but thought it wudnt work cus Wage[$i] wasnt part the for loop...
Well was working away at me program and the only errors i have i think come from the for loops so hopefully when I do this i can be finished with it... then i'll start using it for small programs within work =) This should be fun lol.
Cheers again PBMods!
User Profile
Collapse
-
Converting for loop to foreach
Hey guys i posted up to a reply some other detail but the main point of it is to know how if you use foreach ... can u access different arrays ... take
if you look at http://bytes.co...Code:for ($i = 1; $i <= count($Hours); $i++) //This is compensation for actual work { $actualValues[$i] = $Hours[$i] * $Wage[$i]; $theValue += $actualValues[$i]; } -
Hi guys ive been trying to use these foreach loops and was just looking clarification to find whetehr i am doing it rite.
...Code://Email Variables $EmailFro = $_POST['EmailFrom']; $EmailT = $_POST['EmailTo']; $EmailDat = $_POST['EmailDate']; $EmailSubjec = $_POST['EmailSubject']; $EmailMessag = $_POST['EmailMessage']; foreach ($EmailFro as $i => $temp) { $EmailFrom[$i] = $temp;Leave a comment:
-
U learn something new every day... thanks for explaining it to me cus i know uve got the blog and probs explain everyday of the week but sound1. Ill pass this teaching on LOL. :DLeave a comment:
-
LOL PBMods u hit the nail on the head there... im only outa uni (doing this for dissertation in construction management [yes a major change]) and all i learned was java, cobol, mysql and prolog so what ur saying is 100% but i have looked at foreach code and have not understood it. In ur explanation it is very clear tbh but what is $element, is this the $i or do i go for column headings?Leave a comment:
-
lol hey guys well ive done what u say and fair enuf it works but how do i separate the array i get into smaller parts.
I have tried the usual
for($i=1; $i<=count("theA rray"); $i++) //"theArray" is generic
but this throws an undefined offset which is when the array part im accessing doesnt exist. I have also tried using
explode(",", "theArray")
...Leave a comment:
-
sound one guys in work now but having to work till 10pm gmt the night so uve helped me loads. its in for next friday an i cant work on it over the weekend.
THANKS.Leave a comment:
-
lo markus
just got in from work there the code im using in the html file is basically having
header 1 h2 h3 h4 h5 etc |BUTTON|
There is zero input boxes below this so when you first press button javascript kicks in with the code
...Code:function addActual() { var myTab = document.getElementById('myTable2'); var row=myTab.rows.length; var y=myTab.insertRow(row);Leave a comment:
-
sound one that solved the mysql problem... still have to figure the
Undefined index: EmailFrom[] in /home/moneill/public_html/mainPHP.php on line 37
which are me arrays..Leave a comment:
-
Mixture between html and php- UNIDENTIFIED INDEX
Lo all,
Had me head wrecked the whole week with a really stupid problem that came down to me not reading something but now when im running the php file i have errors switched on and i have bout 15 unidentified index but the problem is that i have used the code
...Code:function addActual() { var myTab = document.getElementById('myTable2'); var row=myTab.rows.length; var y=myTab.insertRow(row); var -
sorry guys i found what the problem was and i feel like a rite plonker...
I have been frustrated with this software so i decided to begin from scratch and add sections of code at a time when i noticed that the error was still on 166 and i only had 60. I checked the error again and low and behold the error says input.html not the mainphp.php.
I was a day away from smashing the computer but ill take her back now :DLeave a comment:
-
lo pbmods,
If you go to the 5th or 6th post i displayed the code that im using. TBH i have tried a lot of things to even by pass the error but it doesnt seem to work and i cant figure it out at all. I did notice last night that a variable in the global ... was not a initialised, r even used, in the program but I dont think this would have caused the error as it would have left it. The value of projectValues was not called global in...Leave a comment:
-
hey guys sorry for the long wait for me to test it i only got to the server comp today. The error remains in the code in the same place...(line 250)
I have traced through the program and have not been able to rectify the problem... I have even taken out validation, isextended and compensation function calls at the bottom of the code but the same error remains.
I am using a companies server, could it be possible that...Leave a comment:
-
sound 1 both of you for helping a newb to php like me. It is appreciated.Leave a comment:
-
Code green
Thanks for the help... but can i ask you how you were able to debug the php without actually having any of the other content, I did not know any software existed as the way i have been debugging is by going to the server using explorer and following it through which only gives one error an line number. It doesnt give that good of a description.
Another point you made was about error_reporting (E_ALL);
...Leave a comment:
-
I thought that too but there i have kept the }'s all in line...
BTW I did a bit extra work (take out some white spaces) before i left today so the program lines have changed a bit.
...Code:<html> <head><title>InputDelayDetails</title></head> <?PHP $link = mysql_connect("localhost", "space", "ashbyLevel4"); // Connect to serverLeave a comment:
-
is my programming really that bad?
You are probably right with the array / variable thing but even when i comment it out or remove it completely it still says there is the same error. In the case of comments it points to the line within the comment. In the case of removing it, the error is still on line 248 only there is different code there. Could it be the way in which i have variables = signs lining up together could cause too...Leave a comment:
-
A Parse error that shouldnt be
Lo all,
Ive been getting the error message
Parse error: parse error, unexpected T_ENCAPSED_AND_ WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/moneill/public_html/input.html on line 248
so ive checked me code over and over again but cant find whats wrong. So getting a annoyed I commented it to move on to next error but the same error message comes up. And when i remove the code completely... -
yeh thats spot on so it is. im going to implement now. Cheers for the help!Leave a comment:
-
micky125 replied to Select statement using a second select statement from same input page to gather infoin PHPthanks for the quick reply appreciated. Ill have another look at some tutorials on AJAX if u say it easy to understand. Thanks for clarifying it.Leave a comment:
No activity results to display
Show More
Leave a comment: