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 5974687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:58:38+00:00 2026-05-22T20:58:38+00:00

<?php // code that connects to database ?> <table> <form method=get action=processorder.php> <?php while

  • 0
<?php
// code that connects to database
?>
<table>

    <form method="get" action="processorder.php">
            <?php
            while (list($pizzaId, $pizzaName, $pizzaNumber, $pizzaPrice) = mysql_fetch_row($resultaat))
                    {

                        echo           "<tr>
                                    <td>".$pizzaName."</td>
                                    <td>".$pizzaNumber."</td>
                                    <td>".$pizzaPrice."</td> 
                                    <td> <input type='text' name='$pizzaId' value='$qty' size='3' /></td>
                                    </tr>";
                    }
            mysql_close($db);        
            ?>
        <input type="submit" value="Order now" />

I would like to display the pizzas of where there is a value in the input element.
the processorder.php file would look like:
my url shows the pizzaId’s with the values after the ‘=’. So I figured I have an associative array on my hands.
I thought I’d put a foreach loop in my processorder.php going like

   foreach ($_GET['pizzaId'] as $pizza => $qty)    
            {
                echo $pizza." ".$qty."<br />";
            }

Yet, when I use the foreach loop, the error in my browser says that the argument of my foreach loop is invalid because $_GET[‘pizzaId’] isn’t an array to begin with (I checked with is_array).
So how do I get access to those values in my value attribute of the input element?

  • 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-05-22T20:58:39+00:00Added an answer on May 22, 2026 at 8:58 pm

    Your $pizzaId is an integer.
    I would change the name of the input elements to name=”pizzas[$pizzaId]”, and then you could access it through PHP like this:

    foreach ($_GET["pizzas"] as $pizzaId => $pizzaQty) {
        echo "$pizzaId $pizzaQty<br />";
    }
    

    with this method, instead of just plain name=”pizzas[]”, you also retain the association with the actual pizzaId.

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

Sidebar

Related Questions

I'm working with some old PHP code that has a lot of the following:
I'm refactoring some PHP code and discovered that certain nested combinations of if ()
What is the simplest, fastest way to complete the PHP code below such that
I've got some code that was at the bottom of a php file that
I got some legacy code that has this: <?PHP if(isset($_GET['pagina'])==homepage) { ?> HtmlCode1 <?php
I have a code snippet written in PHP that pulls a block of text
I have some code on my PHP powered site that creates a random hash
I've got a section of code on a b2evo PHP site that does the
Typically I use E_ALL to see anything that PHP might say about my code
I have some jQuery code. I have called an Ajax function file, file.php, that

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.