jmarx75
asked on
defining variables inside a counter
I am trying to define variables inside a counter for later use. Check this out:
What i want to do is add the counter variable to the $candidateid variable so I can separate them out for later use.
Like I would like $candidateid1, $candidateid2 etc for use in an ajax function. For the life of me I can't get it to work.
I tried things like.
Can anyone help?
$i = 0;
while($candidatelist = mysql_fetch_array($candidates))
{
$i++;
$candidateid = $candidatelist['id'];
}
$candidates comes from a database. The $candidatelist array returns 2 results.What i want to do is add the counter variable to the $candidateid variable so I can separate them out for later use.
Like I would like $candidateid1, $candidateid2 etc for use in an ajax function. For the life of me I can't get it to work.
I tried things like.
$candidateid.$i = $candidateid.$i;
and $candidateid + $i;
But those doesn't seem to work. This seems like a simple thing to do, but i just can't get it to work.Can anyone help?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
eval("\$candidateid".$i." = \"".$candidatelist['id']."