|
Posted by Chuck Anderson on 11/11/77 11:18
Chuck Anderson wrote:
>google@charliefortune.com wrote:
>
>
>
>>I would like to print a table, using a while loop to insert as many
>>blank text fields as players specified by the user. How do I put html
>>inside a php loop.
>>
>>
>>This is what I have....
>>
>><body>
>><form name="results" method="post">
>>Number of players:<input type ="textarea" name="number_players">
>><input name="Submit" type="submit"></form>
>><?php
>> $x=0;
>> while ($x<$number_players){
>> print ("Place : $x<br>");
>> $variable ="<input type="textarea" name=$x>";
>> print($variable);
>> $x++;
>> }
>>
>>
>></body>
>>
>>
>>(I did a search, but didn't understand the answer I found)
>>
>>
>>
>>
>>
>I recently saw a post saying this was bad form or something, but it's
>what I always do. You can use open and close tags all you want, so I
>close php and just put in the HTML (echoing any Php variables):
>
><?php
>$x=0;
>while ($x<$number_players) {
>?>
>/ Place : <?= $x ?> <br>
><input type="textarea" name=<?= $x ?>>
>
>/<?php
>$x++;
>}
>?>
></body>
>
>I find that this makes the script much more readable and it's easier to
>place correct and well structured HTML.
>
>BTW, there is no input type=textarea. It's type=text or if you really
>meant a textarea, they have their own tags <textarea
>name=textareaname></textarea>
>
>
>
Not sure how those slashes (/) got there, but they're not supposed to be
there.
<?php
$x=0;
while ($x<$number_players) {
?>
Place : <?= $x ?> <br>
<input type="textarea" name=<?= $x ?>>
<?php
$x++;
}
?>
</body>
--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Integrity is obvious.
The lack of it is common.
*****************************
[Back to original message]
|