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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
massiveone
Forum Commoner
Posts: 29
Joined: Tue Jun 18, 2002 4:39 pm
Location: Canada
Contact:

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

Post 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";
User avatar
massiveone
Forum Commoner
Posts: 29
Joined: Tue Jun 18, 2002 4:39 pm
Location: Canada
Contact:

doh! the real problem

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
User avatar
massiveone
Forum Commoner
Posts: 29
Joined: Tue Jun 18, 2002 4:39 pm
Location: Canada
Contact:

Post by massiveone »

THANKS
Post Reply