Jump to content

Search the Community

Showing results for tags 'php button click session'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. hello, what am trying to do is that to allow the user choose from a dropdown list items (item by item) and add each, constantly viewing the added items. the added items must be saved in an array (foodSelected). the problem i am facing is with creating is with creating a variable, and incrementing this variable by one each item the user adds an item!! i want that counter for several reason: - array printing - sending the array items to the database i read in the forums something about $_session variables, i tried to implement it.. but still got errors thats the code i wrote, its a calorie counter.. i will appreciate any help <?php session_start(); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Calorie Counter</title> </head> <body> <p>It's Breakfast </p> <p> <form action="" method="post"> <p> <select name="foodType" id="foodType"> <option selected="selected">Labneh</option> <option>Cucumber</option> <option>Tomato</option> <option>Lettuce</option> <option>Cucumber Pickles</option> <option>Olive Oil</option> <option>Cucumber without peal</option> <option>Olive Black</option> <option>Olive Green</option> </select> <input name="submit" type="submit" id="submit" value="add"> </p> </p> </form> <?php if (isset($_POST['submit'])) { chosenItems(); } $_SESSION['counter'] = (!$_SESSION['counter']) ? 0 : $_SESSION['counter']; if($_POST['add']) { $_SESSION['submit']++; } function chosenItems() { $foodSelected[$counter]= $_REQUEST["foodType"]; echo "food added: ", "<BR>"; print_r($foodSelected); } ?> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.