Posted by Dan on 12/07/03 11:55
That seems to be what I want to do except that the symbol is not being
replaced. I just get an empty end of line
(http://bigcharts.marketwatch.com/intchart/frames/frames.asp?symb=)
BKDotCom wrote:
> reading your post again I see you don't want the "?" in your urls.
> That's a result of using the "get" method with your form (the default)
> here's a more complete code for your page:
>
> <?php
>
> $sites = array(
> 'marketwatch' =>
> 'http://bigcharts.marketwatch.com/intchart/frames/frames.asp?symb=%s',
> 'someothersite' => 'http://www.blah.com/?ticker=%s&something=foo',
> );
>
> if ( !isset($_POST['symbol']) )
> $_POST['symbol'] = '';
>
> ?>
>
> <FORM method="POST">
> <INPUT type="text" name="symbol" value="<?php echo
> htmlspecialchars($_POST['symbol']); ?>" />
> </FORM>
>
> <?php
> if ( !empty($_POST['symbol']) )
> {
> // loop through the sites
> foreach ( $sites as $name => $url )
> {
> $url = sprintf($url,urlencode($_GET['symbol'])); // replaces %s with
> your symbol
> echo '<A HREF="'.$url.'">'.$name.'</A><BR />';
> }
> }
> ?>
Navigation:
[Reply to this message]
|