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

  • SEARCH
  • Home
  • 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 7921053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:26:29+00:00 2026-06-03T16:26:29+00:00

Here is a quickie obviously unworking code of an example of what I am

  • 0

Here is a quickie obviously unworking code of an example of what I am looking to do.

Lets say this is a dinner menu, and the echo’s are currently all the foods that are stored in the database. The user selects only the foods they want, and those selections are inserted into another table.

EXAMPLE:

<form method="post" action="entryform3.php">
<?php

SELECT * FROM foods ...etc...etc...

//Say for example whats echoed below at the moment is value: pizza, apple, steak...etc. So this will echo atleast 3 entries.

echo "For dinner, I'd like ". $result['food'] ."?";
echo "<input type=\"checkbox\" name=\"check\" />Click Me<hr></input>";
echo "<input type=\"hidden\" name=\"item_name\" value=\"$result['food']\"/>";

?>

<input type="submit" value="Add Selected Foods" name="submit"></form>


------------entryform3.php-----------
<?php

$food = $_POST['food'];

if (isset($_POST['check'])) {


INSERT INTO selectedfoods "(foods) VALUES '$food'";


}

//made up example... but if user check marks only apple, and steak from the echo, I want only apple and steak to be inserted into database.
?>

I realize there is missing mysql and such, but my problem lies in tying together the checkbox button with an individual value. My partially working code that I took this example from, only takes the very last echoed selection, if any one of the foods is checked.

So, it doesn’t send the correct food choice into the database, only the last echoed –the if statement only notices if any one of the check boxes are selected or not.

Thanks!

  • 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-03T16:26:31+00:00Added an answer on June 3, 2026 at 4:26 pm

    It seems like you miss the name of the checkbox as array. For example, you may write your checkbox like this:

    <input type="checkbox" name="box[]" value="name_of_food" />Name_of_Food<br />
    .......
    .......
    

    then when you get the result, just do like this:

    <?php
           if(isset($_POST['check'])){
               $foods = $_POST['box'];
    
               foreach($foods as $food){
                   echo $food." <br />";
               }
           }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the code in a function I'm trying to revise. This example works
Here this the code that I'm using: progressFrame = (FrameLayout) findViewById(R.id.progressFrame); progressFrame.setBackgroundResource(R.drawable.startprogress); All works
Here is what I am currently doing. PHP echo's out the recent post in
Here is an example. foreach (var doc in documents) { var processor = this.factory.Create();
Here is an example: I write html code inside of textarea, then I swap
Here an example of my checkbox list http://jsfiddle.net/YnM2f/ Let's say I check on G
Here is my question. I am having this simple menu. <div id=menu> <ul> <li>
Quickie here, I'm sure... I am going through some code written by a former
Here's a quickie: Is there a better jquery alternative to remove next all, including
Here is my code: echo '<table class=class1><tbody>'; while ($row1=mysql_fetch_array($result1)){ echo '<tr><td>'.$row1['firstname'].'</td><td>'.$row1['lastname'].'</td></tr>'; } echo '</tbody></table>';

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.