Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7783199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:46:03+00:00 2026-06-01T19:46:03+00:00

I have a form such as the below: <form name=basketSelectionForm action=processBasket.php method=POST> <div id=tabs-1>

  • 0

I have a form such as the below:

<form name="basketSelectionForm" action="processBasket.php" method="POST">
            <div id="tabs-1">
                <table cellpadding="10" cellspacing="10" width="inherit">
                    <tr>
                        <td><img alt="itemNameb" src="images/itemName.jpg" width="70px" height="70px"/></td>
                        <td>Qty. <input value="0" id="itemName" name="basket[itemName]" type="text" style="width:40px;"/>&nbsp; &nbsp; &nbsp;</td>

                        <td><img alt="itemName" src="images/itemName.jpg" width="70px" height="70px"/></td>
                        <td>Qty. <input value="0" id="itemName" name="basket[itemName]" type="text" style="width:40px;"/></td>

Now when I go to second page to look at the entries of the array, I do this:

<?php
    $itemsBasket = array( );
    $itemsBasket = $_POST['basket'];
    echo "<h1>The Items Are...</h1><br>";
    //print_r($itemsBasket);


    foreach ($itemsBasket as $value) 
    {
        if($value > 0){
            echo $value . "<br>";
        }
    }

?>

This will print the value at the indexes of the array…but I need to store the name of the index so lets say the item is chocolate and value of 12. I want to extract that index name from array to store it in variable and then assign value to that variable…

Any way I can do that? right now I get only the value while iterating…

Thanks for help and sorry if question isn’t clear I will help explain better if so…

UPDATE: this is the unexpected output….

whitethoab: Array woolthoab: 22 shemag: 22 undershirt: 1 serwalthoab:
22 socks: 12

and this is the definition of the element showing as two dimensional array…

<td><img alt="White Thoab" src="images/whitethoub.jpg" width="70px" height="70px"/></td>
                        <td>Qty. <input value="0" id="whitethoab" name="basket[whitethoab]" type="text" style="width:40px;"/>&nbsp; &nbsp; &nbsp;</td>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:46:05+00:00Added an answer on June 1, 2026 at 7:46 pm

    Something like:

    <form name="basketSelectionForm" action="processBasket.php" method="POST">
                <div id="tabs-1">
                    <table cellpadding="10" cellspacing="10" width="inherit">
                        <tr>
                            <td><img alt="itemNameb" src="images/itemName.jpg" width="70px" height="70px"/></td>
                            <td>Qty. <input value="12" id="itemName" name="basket[chocolate]" type="text" style="width:40px;"/>&nbsp; &nbsp; &nbsp;</td>
    
                            <td><img alt="itemName" src="images/itemName.jpg" width="70px" height="70px"/></td>
                            <td>Qty. <input value="9" id="itemName" name="basket[onions]" type="text" style="width:40px;"/></td>
    

    …and…

    <?php
    
        echo "<h1>The Items Are...</h1><br>";
    
        foreach ($_POST['basket'] as $name => $value) 
        {
            if($value > 0){
                echo $name . ": " . $value . "<br>";
            }
        }
    
    /* Output:
     chocolate: 12
     onions: 9
    */
    
    ?>
    

    ?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

php page1 --> below bit is pure html: <form action=page2.php method=post> <input type=text name=name
I have such a form: <form id=new-application method=post enctype=multipart/form-data data-remote=true action=/inv/claims?locale=uk accept-charset=UTF-8> <a rel=nofollow
I am new to php. I want to have a form such as this:
I have a HTML form with fields such as name, address, notes, etc. I
I have such code in my JSF template: <h:form> <table id=users cellspacing=0> <a4j:repeat var=person
I have a directory full of log files in the form ${name}.log.${year}{month}${day} such that
I have a form input consisting of two radiobuttons, for one name, as below:
If I have a Django form such as: class ContactForm(forms.Form): subject = forms.CharField(max_length=100) message
If I have .Net Form with a component/object such as a textbox that I
We have a place in a code of such form: void processParam(Object param) {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.