On Wed, 2008-03-05 at 10:28 -0500, 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{
>               $numBox = $_SESSION['num'];
>       }
>       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\">";
>       while($i < $numBox){
> echo <<<HTML
>               <tr>
>               <td>
>               <input type="text" size="5" name="txtNumArray[]"  
> value="txtNumArray[$i]">
>               </td>
>               <td>
>               <input type="text" size="5" name="txtPiecesArray[]"  
> value="txtPiecesArray[$i]">
>               </td>
>               <td>
>               <input type="text" size="5" name="txtWeightArray[]"  
> value="txtWeightArray[$i]">
>               </td>
>               </tr>
> HTML;
>               $i++;
>       
>       }       
> echo "<input type=\"submit\"></form>";
> 
> 
> 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"? :)

I think you want the following after performing a very cursory look at
your sample.

<?php

$NumArray 
    = isset( $_POST['txtNumArray'] )
    ? $_POST['txtNumArray']
    : array();

?>

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to