473,473 Members | 1,460 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Counter syntax problem

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

Apr 20 '06 #1
2 1289
First of all, relying on register_globals=on is just soo bad; Please
use $_GET['varnam'] resp. $_POST['varnam'] for accessing script
parameters instead.

Concerning your problem: You can pass arrays via the GET method by
using array[index] as varname. Use array[] for auto increment of the
index. To print a value, use
<?php=$_GET['array']['index']?>

PS: Use $op++ instead of $po = $po + 1 :)

Apr 20 '06 #2
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.
js*******@attglobal.net
==================
Apr 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: IloChab | last post by:
I'd like to implement an object that represents a circular counter, i.e. an integer that returns to zero when it goes over it's maxVal. This counter has a particular behavior in comparison: if I...
9
by: Pygmalion | last post by:
I have found dozen of useful PHP counters on the web. However, nobody is working for my web pages, since administrator does not want to enable the possibility that PHP could be called from HTML. ...
1
by: BL3WC | last post by:
Hi, I'd created a MDE under Access 2003. It is now under testing stage. Some of the users will use Access 2003 runtime and some will use Access 2007 runtime to run this MDE. I installed the...
7
by: HSXWillH | last post by:
I have a field in a database that contains last names. In some of those names, like O'Brien and O'Connor, there is a ' symbol. I am using combo boxes on a form to build a form filter and in...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.