I have a question similar to this, and from this post I still cannot get it to work right. 🙂
I'm building a table which displays the information in the table. The left most table field will be a Load button to load that entry. So what I need is for the name of the variable to increment, but the value of the variable to reflect the key field inside the table. :p
When I use a loop, and if I use the same var name, the variable is changed each time to the most recently pulled in value. So no matter which button is clicked, only the last one will appear. :p
Here is my code (lots of echos so I can see variables -- this is not working how I want it to):
while($rowresults = sybase_fetch_row($searchresults)) {
while(list($krow, $vcells) = each($rowresults)) {
if ($firsttime=="yes") {
$loadform='$vcells' . $forminc;
echo "loadform: $loadform";
echo "<td><input type='submit' name='selectlog' value='Load'><input type='hidden' name='hiddenlog' value='$loadform'>$loadform</td>";
$firsttime="no";
$forminc++;
}
if ($countme >= 9) {
$loadform='$vcells' . $forminc;
echo "loadform: $loadform";
echo "</tr><td><input type='submit' name='selectlog' value='Load'><input type='hidden' name='hiddenlog' value='$loadform'>$loadform</td>";
$countme=0;
$forminc++;
}
if (($krow==0) or ($krow==7) or ($krow==8)) {
// Don't print the key field, the long description or the long resolution.
// echo "<td>$krow</td>";
} else {
echo "<td class='underbold' align='left' valign='top'>$vcells</td>";
}
$countme++;
}
}