Jump to content

Search the Community

Showing results for tags 'solution'.

  • 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. I have been tasked to create a small program in any language I know, which is PHP. It will be a console app (I can't install a LAMP stack etc) and it has to: Allow one of six minibeasts to be selected from a menu Enter and store the name and grid co-ordinates of the selected minibeast Display how often each minibeast was found Display the minibeasts found in each grid co-ordinate So far in PHP I have got a welcome screen, then some of the menu from which they can input what minibeast they want to select information for (sort of). I have the actual menu worked out, it's a simple "echo" after all, but I need to work out how to execute different code based on their input. This is my main file: require_once 'functions.php'; require_once 'config.php'; welcome(); // Adds the welcome message to the program menu(); // Adds the selection menu to the console app getUserInput(); This is functions.php with all my functions: <?php // This holds all of the functions for the // program // Welcome function (just text really) function welcome(){ echo " Welcome to the console application. "; echo " To begin using the program, type a number from the list below and then press \"ENTER\" to execute it. "; echo " For help, type \"help\" and execute it, for credits type \"credits\" and execute and for prog. info type \"info\". Version $vernumber "; } // Next is the selection menu function menu(){ echo " Please execute a number from below: 1. Slug 2. Centipede 3. Ladybird 4. Snail 5. Woodlouse 6. Worm 7. Exit "; } // Add the input catcher function getUserInput(){ fwrite(STDOUT, "Enter your choice\n"); $selected = fgets(STDIN); if ($selected = "1"){ echo "hi"; } elseif($selected = "2"){ } } ?> This is where the problems start. I take their input as $selected, but the if statement is for some reason not working. Then I need to work out how to execute the function again if they enter nothing. Could this be accomplished in a while.. loop? Thanks a lot
×
×
  • 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.