deesse Posted August 30, 2007 Share Posted August 30, 2007 Hi All, Hope I can get some help from you here. I am using command line, and the following script works fine. Problem 1: I would like to have a link or call function to these sites below(in the same script if possible), like if the user picks 'b' (Site2), then this script can point to the specific item. I have additional PHP scripts such as config.php, download.php. How can I include download.php in this script to be called automatically when the user makes a choice. The choice comes first and then download follows. Problem 2: How to insert error handler in this script? Like if the user mistakenly input a wrong choice...eg: m instead of c. Hope to get some comments soon... thanks in advance for reading! <?php fwrite(STDOUT, "Pick a site link (enter the letter and press return)\n"); // An array of choice to sites $sites = array ( 'a'=>'Site1', 'b'=>'Site2', 'c'=>'Site3', 'd'=>'Site3', ); fwrite(STDOUT, "Enter 'q' to quit\n"); // Display the choices foreach ( $sites as $choice => $site ) { fwrite(STDOUT, "\t$choice: $site\n"); } // Loop until they enter 'q' for Quit do { // A character from STDIN, ignoring whitespace characters do { $selection = fgetc(STDIN); } while ( trim($selection) == '' ); if ( array_key_exists($selection,$sites) ) { fwrite(STDOUT, "You picked {$sites[$selection]}\n"); } } while ( $selection != 'q' ); exit(0); ?> Quote Link to comment https://forums.phpfreaks.com/topic/67295-solved-php-script-expension/ Share on other sites More sharing options...
deesse Posted August 31, 2007 Author Share Posted August 31, 2007 Please help.....!!!! I am still trying to figure out how to deal with by creating/adding some php scripts to link..... Quote Link to comment https://forums.phpfreaks.com/topic/67295-solved-php-script-expension/#findComment-338135 Share on other sites More sharing options...
teng84 Posted August 31, 2007 Share Posted August 31, 2007 meeen not clear are talking about include? Quote Link to comment https://forums.phpfreaks.com/topic/67295-solved-php-script-expension/#findComment-338141 Share on other sites More sharing options...
deesse Posted August 31, 2007 Author Share Posted August 31, 2007 Well include could be part of it...but I would like the following order to take place: 1- user chooses a site first 2- download begins after that choice. I wish i could use include() but I am afraid this will start first before the user makes a choice of which site to navigate. So how to do that ? hope this is clearer.... thanks again... Quote Link to comment https://forums.phpfreaks.com/topic/67295-solved-php-script-expension/#findComment-338453 Share on other sites More sharing options...
deesse Posted September 2, 2007 Author Share Posted September 2, 2007 Hi again,,, Is it possible to combine array and echo or print together????? I would like to use echo or print in the array....how to go about that? Like once all the sites are displayed, there could be one line description of each one of them. The result shoud look like this: Enter 'q' to quit a: sites {one line description goes here....} but how? b: site2 {one line description goes here....} " c: site3 {another line description goes here....} but how? d: site4 {another line description goes here....} " e: site5 {another line description goes here....} " thanks...! Quote Link to comment https://forums.phpfreaks.com/topic/67295-solved-php-script-expension/#findComment-339700 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.