You are here: Re: printing html table elements inside php script « PHP Programming Language « IT news, forums, messages
Re: printing html table elements inside php script

Posted by Chuck Anderson on 09/27/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.
*****************************

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация