Page 1 of 1

fun with text boxes and arrays. last element gets axed help?

Posted: Tue Jul 01, 2003 9:10 am
by massiveone
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";

doh! the real problem

Posted: Tue Jul 01, 2003 9:35 am
by massiveone
The Real Problem after some pain staking tests is that one of my skus
has a space in it!!!! how do i get it to work with spaces...
any ideas?
Thanks

Posted: Tue Jul 01, 2003 10:15 am
by volka
by quoting the values
compare

Code: Select all

<input type=text value=with a blank>
to

Code: Select all

<input type="text" value="with a blank" />
in the first element the browser has no chance to determine what belongs to value and what might be the next parameter

Posted: Tue Jul 01, 2003 10:32 am
by massiveone
THANKS