tags:

views:

54

answers:

1

Hi There I am hoping that someone can help me with this php issue.

i would like to get the number into the form from this Loop function

for($i = 1; $i <= 100; $i++)
{
    echo '<textarea name="textarea" id="textarea" cols="100" rows="10">'.spin($string, false).'</textarea>';
    echo '<textarea name="textarea" id="textarea" cols="100" rows="10">'.spin($string, false).'</textarea>';
}

any idea on how I can implement it as to number the textarea(s) from 1 to 100

Thanks

+4  A: 

Use string concatenation ., a number will be automatically converted to a string:

for($i = 1; $i <= 100; $i++)
{
    echo '<textarea name="textarea" id="textarea' . $i . '" cols="100" rows="10">'.spin($string, false).'</textarea>';
}

Or if you want to actually display the number:

for($i = 1; $i <= 100; $i++)
{
    echo $i . '. <textarea name="textarea" id="textarea' . $i . '" cols="100" rows="10">'.spin($string, false).'</textarea>';
}

If this is not what you want to have to clarify what you want.


Note: An ID has to be unique for any HTML element. In your code, you generate 100 textareas with the same ID.

Felix Kling
Thanks Felix this is exactly what I looked for... I tried to do it as .i. but not with the $ :-)...
Gerald Ferreira
@Gerald Ferreira: You're welcome. Variables always start with `$` ;)
Felix Kling
Note: An ID has to be unique for any HTML element. In your code, you generate 100 textareas with the same ID.I am using asp but needed a php function. Now I can submit the 100 texarea's to my php and pick up the values there!
Gerald Ferreira