Connecting Tech Pros Worldwide Forums | Help | Site Map

how do i increment inside a loop?

Newbie
 
Join Date: Aug 2006
Posts: 12
#1: Aug 9 '06
initialize a var to 1 outside of your mysql_fetch_array() loop. Then, within the mysql_fetch_array() loop, use the var as necessary and increment it by 1

iam_clint's Avatar
Forum Leader
 
Join Date: Jul 2006
Location: Oklahoma
Posts: 1,076
#2: Aug 9 '06

re: how do i increment inside a loop?


you do it exactly as you said :P

var = 1
loop
var = var + 1
data
end loop
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#3: Aug 9 '06

re: how do i increment inside a loop?


Am I missing something here? What was the question?

Ronald :cool:
Newbie
 
Join Date: Aug 2006
Posts: 12
#4: Aug 9 '06

re: how do i increment inside a loop?


ok maybe not clear in what i wanted

i have this
$pos=1
where do i put the loop in this
($row = mysql_fetch_array($result, MYSQL_ASSOC))
iam_clint's Avatar
Forum Leader
 
Join Date: Jul 2006
Location: Oklahoma
Posts: 1,076
#5: Aug 9 '06

re: how do i increment inside a loop?


$pos=1
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
$pos=$pos + 1
Newbie
 
Join Date: Aug 2006
Posts: 12
#6: Aug 9 '06

re: how do i increment inside a loop?


thank you iam_clint i had trouble putting it wher i wanted it at first then put it in the correct place in place of $row[$pos]

thank you again
Reply