Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic variable assignment

Status
Not open for further replies.

newbiepg

Programmer
Nov 6, 2002
181
IN
I have a form that may have variable number of rows but has a fixed number of columns

I want to fetch these variables with dynamic variable assignment

e.g. first form has 2 rows with 2 columns
I have named the variables
$t1,$a1 for the first row
$t2,$a2 for the second row

if there would be a third row they would be named
$t3, $a3 and so on
I can also get the number of rows in a variable say $count

Now in the second form how can I fetch them dynamically ?

I am using 4.06 version of PHP


 
I would strongly suggest abandoning that way of thinking and looking into arrays, then
$t[1], $a[1] would be your first row.... or if you want you could have a 2-dimensional array such that

$cell[1][1], $cell[1][2]
be your first row, then you can have a variable number of rows and columns.

If you're stuck on dynamically naming variables there is a way, and someone always gets around to posting it, but I'm not sure what it is as I've never found a case where it's better than an array.

-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top