Hi, Sunday, March 7, 2004, 11:20:18 PM, you wrote: L> Hi, thanks for a help. but your script doesn't work correctly.
L> function output($action){ // this is line 64. L> $output = ''; //if no file we return an empty string L> $fname = 'data/'.$action.'.txt'; L> if(file_exists($fname)){ L> $file = file($fname); L> foreach($file as $value ) { L> $output .= "$value<br>"; L> } L> } L> return $output; L> } L> $content = output(); // I added this line because later I have an echo.. L> if(isset($_REQUEST['action'])){ L> $out = output($_REQUEST['action']); L> } L> echo "<tr><td>".$content."<td><tr>"; // as you can see, it is important to L> put whole output of the function to this variable ($content). L> The browser debugs: L> Warning: Missing argument 1 for output() in C:\www\RKV\start.php on line L> 64 L> Sorry for my bad english, L> Roman L> ----- Original Message ----- L> From: "Tom Rogers" <[EMAIL PROTECTED]> L> To: "Labunski" <[EMAIL PROTECTED]> L> Cc: <[EMAIL PROTECTED]> L> Sent: Sunday, March 07, 2004 4:14 AM L> Subject: Re: [PHP] How to write this correctly? You only need to call output if there is an action selected so try something like this then function output($action){ $output = ''; //if no file we return an empty string $fname = 'data/'.$action.'.txt'; if(file_exists($fname){ $file = file($fname); foreach($file as $value ) { $output .= "$value<br>"; } } return $output; } echo '<table>'; if(isset($_REQUEST['action'])){ $content = output($_REQUEST['action']); if(!empty($content)){ echo "<tr><td>".$content."</td></tr>"; }else{ echo '<tr><td>Sorry '.$_REQUEST['action'].' not found!</td></tr>'; }else{ ?> <tr> <td> <a href='index.php?action=industry'>Factories</a><br> <a href='index.php?action=art'>Beautiful pictures</a><br> <a href='index.php?action=animals'>Zoo</a><br> <a href='index.php?action=contact'>Contact us</a> </td> </tr> <?php } echo '</table>'; -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php