smith.james0 Posted December 15, 2006 Share Posted December 15, 2006 I would like to echo this <input type=\"text\" name=\"$i[]\" />but the page won't work unless i take out the [] Do you need somthing either side of the [] ?Many thanks James Link to comment https://forums.phpfreaks.com/topic/30796-simple-echo-question/ Share on other sites More sharing options...
complex05 Posted December 15, 2006 Share Posted December 15, 2006 echo("<input type=\"text\" name=\"" . $i[] . "\">"); Link to comment https://forums.phpfreaks.com/topic/30796-simple-echo-question/#findComment-141990 Share on other sites More sharing options...
SharkBait Posted December 15, 2006 Share Posted December 15, 2006 Or [code]<?phpecho "<input type=\"text\" name=\"{$i[]}\">";?>[/code] Link to comment https://forums.phpfreaks.com/topic/30796-simple-echo-question/#findComment-141995 Share on other sites More sharing options...
smith.james0 Posted December 15, 2006 Author Share Posted December 15, 2006 Thanks for the quick responce. I have tried both ways, but neather of them work, i have copied both from this page.Thanks James Link to comment https://forums.phpfreaks.com/topic/30796-simple-echo-question/#findComment-142014 Share on other sites More sharing options...
complex05 Posted December 15, 2006 Share Posted December 15, 2006 post your whole code, maybe ur probably is $i isn't an array. Link to comment https://forums.phpfreaks.com/topic/30796-simple-echo-question/#findComment-142024 Share on other sites More sharing options...
smith.james0 Posted December 15, 2006 Author Share Posted December 15, 2006 Is code works fine like is Units: <input type="text" name="<? echo $i; ?>[]" />the array works finewhen the above examples are tested I just get a blank page. The only way to get it to output is to remove the []<?phpecho "Sales <input type=\"text\" name=\"{$i}\">";?>But the array doesn't work Thanks James Link to comment https://forums.phpfreaks.com/topic/30796-simple-echo-question/#findComment-142032 Share on other sites More sharing options...
complex05 Posted December 15, 2006 Share Posted December 15, 2006 what do you want to be displayed? $i[] is an array and shouldn't output anything; you need to specify a key... like $i[1] etc... Link to comment https://forums.phpfreaks.com/topic/30796-simple-echo-question/#findComment-142043 Share on other sites More sharing options...
smith.james0 Posted December 15, 2006 Author Share Posted December 15, 2006 I have this looped 14 times <?php echo "$i $disp_date"; ?> <input type="hidden" value="<?php echo $time; ?>" name="<? echo $i; ?>[]" />Sales: <input type="text" name="<? echo $i; ?>" /> Units: <input type="text" name="<? echo $i; ?>[]" />Extra : <input type="text" name="<? echo $i; ?>[]" /><br>So i get this informtion in the $_POST arrayArray( [1] => Array ( [0] => 1165708800 (Hidden field) [1] => test1 (Sales) [2] => test2 (Units) [3] => test3 (Extra) ) [2] => Array ( [0] => 1165795200 [1] => [2] => [3] => ) [3] => Array ( [0] => 1165881600 [1] => [2] => [3] => )etc..The four bits of information in each array are put into a dbThanks James Link to comment https://forums.phpfreaks.com/topic/30796-simple-echo-question/#findComment-142054 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.