I won't address the main issue of your question, since it looks like that has
been solved. But I want to point out a few other things that might help you.
Follow along below...
Jason Pruim wrote:
So for some reason, arrays always mess me up... I don't know what it is,
but it just hasn't clicked yet... So I'm sure this is a simple question
for someone who knows and understands arrays :)
So with that being said here's the code I'm using:
$self = $_SERVER['PHP_SELF'];
$i="0";
if (isset($_GET['txtNum'])) {
$numBox= $_GET['txtNum'];
$_SESSION['num'] = $_GET['txtNum'];
}else{
here you need to make sure that $_SESSION['num'] exists.
If not you will get a E_NOTICE warning level error.
So, you should have this
} else if ( isset($_SESSION['num']) ) {
$numBox = $_SESSION['num'];
}
And then follow up the previous thing with this else statement
} else {
echo 'no "num" set';
// AND / OR
$numBox = 0;
}
echo "store box variable". $_SESSION['num'];
echo <<<HTML
<form method="GET">
How many boxes? <input type="text" size="2" name="txtNum">
<BR>
<input type="submit"></form>
HTML;
$NumArray= Array($_POST['txtNumArray[]']);
echo <<<TABLE
<P>Weight of 100 pieces: <input type="text" size="5"
name="txtPieceWeight"></P>
<table border="1"><tr><th>Route #</th><th>Pieces in
route</th><th>Weight of route</th></tr>
TABLE;
echo "<form method=\"POST\" action=\"$self\">";
Change this to "post" <-- spec says lower case on the value
And, you could get rid of the echo and move it to the last line of the previous
HEREDOC statement
while($i < $numBox){
echo <<<HTML
<tr>
<td>
<input type="text" size="5" name="txtNumArray[]"
Here you would use just value="txtNumArray[{$i}]"
value="txtNumArray[$i]">
Here you would use just value="{$i}"
</td>
<td>
<input type="text" size="5" name="txtPiecesArray[]"
Here you would use just value="txtPiecesArray[{$i}]"
value="txtPiecesArray[$i]">
Here you would use just value="{$i}"
</td>
<td>
<input type="text" size="5" name="txtWeightArray[]"
Here you would use just value="txtWeightArray[{$i}]"
value="txtWeightArray[$i]">
Here you would use just value="{$i}"
</td>
</tr>
HTML;
$i++;
}
echo "<input type=\"submit\"></form>";
The reason I would do the above, is to make sure that all three arrays are in sync.
What I'm attempting to do, is grab the info out of txtNumArray[] and put
it into the variable $numArray Sounds easy enough right? Well I've tried
using $NumArray = Array($_POST['txtNumArray[]'); but that's not
working... I've tried $NumArray = $_POST['txtNumArray[]']; which didn't
work... and I've looked on the php manual, but they all assume you
understand this stuff which I do not :)
Anyone know what I'm doing wrong? Or could at least point me to some
text like "Array's for Dummies"? :)
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
japruim@xxxxxxxxxx
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php