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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting text

Status
Not open for further replies.

neilmurray

Technical User
Jan 18, 2005
32
GB
Hi,

I have selected a row from a table where the column names are:

id, money, com1, com2, com3, com4, com5, com6

I want to do a loop where I run a function on each one of the com1, com2 etc. values one at a time.

Is there any way I can format the text to be say

for ($i=1;$i<=20;$i++)
{
$answer = com$i +whatever
}

So I can run the same loop for each of the com values.

Thanks,

Neil.
 
It depends on the language and database interface you're using. I don't know much PHP, but I think you could do something like:[tt]
$answer = $row["com".$i] + $whatever;[/tt]
where the '.' represents the PHP string concatenation operator, whatever that is.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top