can I assign a number to the name value in a text field?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
michlcamp
Forum Commoner
Posts: 78
Joined: Mon Jul 18, 2005 11:06 pm

can I assign a number to the name value in a text field?

Post by michlcamp »

I'm using a while loop to query products from a table to create an orderform. Works fine.
The products and descriptions "echo" on the page to create the orderform and a text field named "qty" for quantity ordered is written for each product in the table. This is where the customer puts in how many of each product they want to buy.

It writes like this:

Code: Select all

while..blah blah blah..

echo "$product - Qty: <input type=\"text\" name=\"qty\" size=2><br>";
My question:
How do I assign ascending numbers to each "qty" field?
I'd like the output to be:

product 1 : <input type=\"text\" name=\"qty1\" size=2><br>
product 2 : <input type=\"text\" name=\"qty2\" size=2><br>
product 3 : <input type=\"text\" name=\"qty3\" size=2><br>

and so on..

the products part is already working, I'm just after how to write the code that will add a number to the "qty" field for each.

Thanks in advance.
mc
Last edited by michlcamp on Wed Oct 12, 2005 5:42 pm, edited 3 times in total.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

You can certainly put numbers in there, either before, after, or instead of 'qty'. However, having a field like '001qty' will not validate XHTML 1.0. It'll still work fine, it just won't validate.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
michlcamp
Forum Commoner
Posts: 78
Joined: Mon Jul 18, 2005 11:06 pm

got it

Post by michlcamp »

got it..dumb question
Post Reply