Jump to content


This topic is now archived and is closed to further replies.


Simple Loop Syntax Problem - Please Help!

Recommended Posts

Hey guys, i have this loop which is causing me problems and i'm not sure why. I assume it's a syntax problem but i just can't seem to identify the issue. Can anyone help me pleaaase!!!!

for($i = 0; $i < 20); $i++) {
<input type="hidden" name="suburb<?php echo $i; ?>" value="<?php echo $_POST['suburb$i']; ?>" />

Share this post

Link to post
Share on other sites
You have a right parenthesis after the 20, and you're using single quotes in the $_POST array key. Try:

for ($i = 0; $i < 20; $i++) {
    echo '<input type="hidden" name="suburb', $i, '" value="', $_POST["suburb$i"], '" />';


While testing/debugging this, make sure you have error_reporting(E_ALL); at the top of your script so you can see all of PHP's errors/warnings/notices. Also, have display_errors on in the php.ini file. Otherwise, set it using ini_set('display_errors', '1'); at the top of your script too.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.