Muiter Posted April 28, 2010 Author Share Posted April 28, 2010 Ok, print_r now gives: Array ( [0] => [1] => [2] => [3] => ) Array ( [0] => [1] => [2] => [3] => ) Array ( [0] => [1] => [2] => [3] => ) Link to comment Share on other sites More sharing options...
justsomeguy Posted April 28, 2010 Share Posted April 28, 2010 Sounds like it didn't find anything, or nothing was submitted. Use print_r on $_POST to print all of the form data out, you can use that to figure out what the data is and how to access it. Link to comment Share on other sites More sharing options...
Muiter Posted April 29, 2010 Author Share Posted April 29, 2010 Print_r on $_POST gives [Array] => Array ( [0] => 1 [1] => 6 [2] => 1 [3] => 4 [4] => 5 [5] => 6 [6] => 5 ) Link to comment Share on other sites More sharing options...
justsomeguy Posted April 29, 2010 Share Posted April 29, 2010 So $_POST is an array with 7 numbered values. It looks like it doesn't include any data with a name, just numbers. Are you changing $_POST somewhere in the code? Link to comment Share on other sites More sharing options...
Muiter Posted April 29, 2010 Author Share Posted April 29, 2010 Ok, I´m one step closer.....Now I have this result when using print_r on _POST [calculatie_id0] => Array ( [0] => 1 [1] => 4 [2] => 5 [3] => 6 ) [calculatie_id1] => Array ( [0] => 4 ) [calculatie_id2] => Array ( [0] => 1 [1] => 6 ) Link to comment Share on other sites More sharing options...
justsomeguy Posted April 29, 2010 Share Posted April 29, 2010 Right, that looks better. So you can access each of those arrays by name. Link to comment Share on other sites More sharing options...
Muiter Posted May 1, 2010 Author Share Posted May 1, 2010 Ok but how to do that? This is what I thought: for ($i=0; $i<=$aantal_regels; $i++) { $calculatie_lst[$i] = $_POST[$calculatie_id][$i]; } and <?php for ($i=0; $i<=$aantal_regels_corr; $i++) { foreach ($calculatie_lst[$i] as $value) { echo $value; } ?> Link to comment Share on other sites More sharing options...
thescientist Posted May 3, 2010 Share Posted May 3, 2010 the second condition in a for loop requires a number. Typically when searching through arrays, one would tend to use the length method to have the for loop check through all index's. for (i=0; i<=myArray.length; i++){ //check for what you're looking for}; Link to comment Share on other sites More sharing options...
dsonesuk Posted May 3, 2010 Share Posted May 3, 2010 myArray.length is for javascript, count($myArray) is for PHP Link to comment Share on other sites More sharing options...
thescientist Posted May 4, 2010 Share Posted May 4, 2010 myArray.length is for javascript, count($myArray) is for PHPhaha, woops!hopefully the OP gets the idea Link to comment Share on other sites More sharing options...
Muiter Posted May 4, 2010 Author Share Posted May 4, 2010 One step closer again. <?php print_r($calculatie_id); for ($i=0; $i<=$aantal_regels_corr; $i++) { ?> <tr> <td> <?php foreach ($calculatie_id[$i] as $value) { echo $value; } ?> print_r($calculatie_id); gives Array ( [0] => Array ( [0] => 4 [1] => 6 ) [1] => Array ( [0] => 1 [1] => 5 ) [2] => Array ( [0] => 5 [1] => 6 ) [3] => )But when using the foreach I only get 46 Link to comment Share on other sites More sharing options...
dsonesuk Posted May 4, 2010 Share Posted May 4, 2010 where exactly is the value for $aantal_regels_corr coming from? in the for loop. Link to comment Share on other sites More sharing options...
Muiter Posted May 5, 2010 Author Share Posted May 5, 2010 where exactly is the value for $aantal_regels_corr coming from? in the for loop. <?phpif ($aantal_regels == ""){ $aantal_regels = 5;}$aantal_regels_corr = $aantal_regels-"1";$aantal_regels_oud = $aantal_regels;?> This part works for the rest of my form. Link to comment Share on other sites More sharing options...
Muiter Posted May 6, 2010 Author Share Posted May 6, 2010 Someone? Link to comment Share on other sites More sharing options...
thescientist Posted May 6, 2010 Share Posted May 6, 2010 are you trying to subtract 1 or a string with the value "1"? building off what dsonesuk said, what is the value of $aantal_regels_corr at the time of the for loop? Also, just emphasize specificity, it should be you printing out the value using print_r or something, not just assuming it should be something you're expecting it to be (or else it would be working). Link to comment Share on other sites More sharing options...
ShadowMage Posted May 6, 2010 Share Posted May 6, 2010 if ($aantal_regels == ""){ $aantal_regels = 5;}$aantal_regels_corr = $aantal_regels-"1";$aantal_regels_oud = $aantal_regels; Where is the value for $aantal_regels coming from?What we're really getting at here is that somewhere in your code $aantal_regels_corr is being set to 0. Which means that your loop...for ($i=0; $i<=$aantal_regels_corr; $i++) { ?> <tr> <td> <?php foreach ($calculatie_id[$i] as $value) ...is only going to run once. Link to comment Share on other sites More sharing options...
Muiter Posted May 7, 2010 Author Share Posted May 7, 2010 Many thanks for helping me out this far but all the examples I try to implement are not working.I have been trying this script for over 2 weeks now. It seems I'm going all the wrong way.I have put my code online at www.pws.nl/downloads/sp_offerte_add.rar. It must be easier then what I'm writing in the code right now. Link to comment Share on other sites More sharing options...
Muiter Posted May 14, 2010 Author Share Posted May 14, 2010 No worry, problem sorted. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.