简体   繁体   中英

How Get value of textarea from a HTML Array

I am trying to get the value of the array of a html form shown below and display using php. But my code seems to have an issue.
Please assist.

html array

<textarea   rows="1"  maxlenth = "20" class="round"    id="quantityid[]" name="quantityname[]"><?php echo $itemsale["quantity"]; ?></textarea>
<td align="center"><?php echo '<span class="remove-itm"><a href="add_sales.php?saveep='.$itemsale["productname"].'&return_url='.'add_sales.php'.'"><img src="images/saveicon.png" width="30" height="30" /></a></span>'; ?></td>

<textarea   rows="1"  maxlenth = "20" class="round"    id="quantityid[]" name="quantityname[]"><?php echo $itemsale["quantity"]; ?></textarea>
<td align="center"><?php echo '<span class="remove-itm"><a href="add_sales.php?saveep='.$itemsale["productname"].'&return_url='.'add_sales.php'.'"><img src="images/saveicon.png" width="30" height="30" /></a></span>'; ?></td>

<textarea   rows="1"  maxlenth = "20" class="round"    id="quantityid[]" name="quantityname[]"><?php echo $itemsale["quantity"]; ?></textarea>
<td align="center"><?php echo '<span class="remove-itm"><a href="add_sales.php?saveep='.$itemsale["productname"].'&return_url='.'add_sales.php'.'"><img src="images/saveicon.png" width="30" height="30" /></a></span>'; ?></td>

my php code

if(isset($_GET["saveep"]) && isset($_GET["return_url"]) && isset($_SESSION["cart_sales"]))
{
    $product_code   = $_GET["saveep"]; //get the product code to remove
    $return_url     = base64_decode($_GET["return_url"]); //get return url

    foreach( $_POST['quantityname'] as $v ) {
     echo $v;
    }
}

Each element inside the form must have an unique name attribute.

Unless you treat your data to client-side to send an array, you won't be able to retrieve an array with $_POST['quantityname'] .

Most likely only one field will be sent.

Check this question for a nice solution to your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM