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!

[code]
<?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); 
?>
[/code]
       
---------------------------------
Be smarter than spam. See how smart SpamGuard is at giving junk email the boot 
with the All-new Yahoo! Mail  

[Non-text portions of this message have been removed]

Reply via email to