fun with text boxes and arrays. last element gets axed help?
Posted: Tue Jul 01, 2003 9:10 am
If anyone can help with this problem that would be great. I have writen a program that pulls data from a table skus and quantity, i stuff the items into an array and have a form print the data (part 1). after it is submitted i do a check for the array yes (part 2) which brings back all the skus and updated quantitys except for some reason it always keeps taking the last element of the sku out/or perhaps not displaying?. any ideas anyone?
part 1
print "<form>";
echo "<center><table bgcolor='E0FFFF' border=1>";
print "<tr><td><b>SKU</b></td><td>quantity on hand</td><td>quantity sold</td></tr>";
foreach ($skus as $sk => $qt ) {
print "<tr><td>$sk</td><td align='right'>$qt</td>";
printf(" <td> <input type='text' name=yes[%s] value='0'> </td>\n",$sk);
print "</tr>";
}
print "<tr><td></td><td></td><td><input type=submit value='invoice now'></td></tr>";
echo "</table></center>";
print "<input type=hidden name=option value='invoice'>";
print "<input type=hidden name=suboption value=1>";
print "</form>";
part 2
if ($suboption) {
print "<center><table border=1>";
if (is_array($yes)) {
foreach ($yes as $sk => $qt) {
print "<tr><td>Sku</td><td>$sk</td><td>Amount</td><td>$qt</td></tr>";
}
print "</table></center>";
} print "finished";
part 1
print "<form>";
echo "<center><table bgcolor='E0FFFF' border=1>";
print "<tr><td><b>SKU</b></td><td>quantity on hand</td><td>quantity sold</td></tr>";
foreach ($skus as $sk => $qt ) {
print "<tr><td>$sk</td><td align='right'>$qt</td>";
printf(" <td> <input type='text' name=yes[%s] value='0'> </td>\n",$sk);
print "</tr>";
}
print "<tr><td></td><td></td><td><input type=submit value='invoice now'></td></tr>";
echo "</table></center>";
print "<input type=hidden name=option value='invoice'>";
print "<input type=hidden name=suboption value=1>";
print "</form>";
part 2
if ($suboption) {
print "<center><table border=1>";
if (is_array($yes)) {
foreach ($yes as $sk => $qt) {
print "<tr><td>Sku</td><td>$sk</td><td>Amount</td><td>$qt</td></tr>";
}
print "</table></center>";
} print "finished";