You are here: Re: Counter syntax problem « PHP Programming Language « IT news, forums, messages
Re: Counter syntax problem

Posted by Jerry Stuckle on 10/12/99 11:45

Garry Jones wrote:
> I am having a problem with php syntax.
>
> I am sending these values to a form called preview.php but I can not get the
> syntax working properly.
>
> $fornamn1
> $eftnamn1
> $fornamn2
> $eftnamn2
>
> On preview.php I want to use a counter in the names like this.
>
> <php
> $po = 1;
> ?>
>
> <?= $fornamn.$po ?>&nbsp;<?= $eftnamn.$po ?>
>
> <?php
> $po = $po + 1;
> ?>
>
> <?= $fornamn.$po ?>&nbsp<?= $eftnamn.$po ?>
>
> I know the values are being sent to preview.php correctly because if I
> substitute $po for real numbers everything is displayed correctly.
>
> Ie
>
> <?= $fornamn1 ?>&nbsp;<?= $eftnamn1 ?>
> <?= $fornamn2 ?>&nbsp;<?= $eftnamn2 ?>
>
> works.
>
> But I want to simplify the code. So how do I get
>
> <?= $fornamn.$po ?>
>
> to actually call fornamn1
>
> Any help greatly appreciated.
>
> Garry Jones
> Sweden
>
>
>

Garry,

First of all, $formname isn't defined. It should be 'formname'. Second, use
the increment (++) operator, i.e. (not checked for syntax)

<?$po = 0; ?>

<?= "formnamn[$po]"; ?>&nbsp;<?="eftnam$po++";?>


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

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

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