473,230 Members | 1,618 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,230 software developers and data experts.

Form to append text to end of choice of URL's

Dan
Hi all-
I am trying to create a simple webpage to save me some time. The
general idea is create a form where I can type in the ticker symbol of
a company (ex: MSFT) and then select a bunch of different sites from
buttons or links to financial sites such as Yahoo Finance, BigCharts,
Routers, etc. Each of those financial sites has a different format for
their URLs such as
http://bigcharts.marketwatch.com/int....asp?symb=MSFT.
What I want to do is take all of these different URLs and just have it
add whatever symbol I choose at the end of them.

I am running into a few problems though. I can create a form to submit
to one site, but I do not know how to have a dozen or so links all use
the input from one text field. Also, I do not now how to code the part
to append the text to the end either. I can pass a variable but it
always includes the "?" which I don't want.

If anyone can provide any help or places to get started I would really
appreciate it! Thank you,
-Dan

Aug 14 '06 #1
6 2694
$sites = array(
'marketwatch' =>
'http://bigcharts.marketwatch.com/intchart/frames/frames.asp?symb=%s',
'someothersite' ='http://www.blah.com/?ticker=%s&something=foo',
);

// loop through the sites
foreach ( $sites as $url )
{
echo sprintf($url,$_GET['symbol']); // replaces %s with your symbol
}

Aug 14 '06 #2
Dan
I'm sorry I am trying to figure this out and I need a little more help.
I am fairly new to this and while I understand the logic I am not sure
exactly where to place this. Can I just use a regular form? If so, do
I have a separate submit button for each site I want to use? Thanks
again for your help,
-Dan
BKDotCom wrote:
$sites = array(
'marketwatch' =>
'http://bigcharts.marketwatch.com/intchart/frames/frames.asp?symb=%s',
'someothersite' ='http://www.blah.com/?ticker=%s&something=foo',
);

// loop through the sites
foreach ( $sites as $url )
{
echo sprintf($url,$_GET['symbol']); // replaces %s with your symbol
}
Aug 14 '06 #3
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 />';
}
}
?>

Aug 14 '06 #4
Dan
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/int...ames.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 />';
}
}
?>
Aug 14 '06 #5
"typo"
I didn't change the $_GET['symbol'] from my frist post to
$_POST['symbol']
make the change and all is well

Dan wrote:
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/int...ames.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 />';
}
}
?>
Aug 14 '06 #6
Dan
I just figured that out as well. Thanks for all your help!
-Dan
BKDotCom wrote:
"typo"
I didn't change the $_GET['symbol'] from my frist post to
$_POST['symbol']
make the change and all is well

Dan wrote:
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/int...ames.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 />';
}
}
?>
Aug 14 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Tom | last post by:
I have created the following code for a product select/payment form (don't know if there is a better way) and I have been trying to make the following changes (unsuccessfully so far): 1) ...
13
by: MLH | last post by:
I have a form with two controls: !! - combo box !! - text box A button on the form tries to run this SQL when clicked... INSERT INTO BodyMsgsSent (ToWhom, BodyText) SELECT DISTINCTROW !! AS...
3
by: Chris | last post by:
Hi, I'm trying to append text from another class to a generic richTextBox that I've added to a Windows form. I can't seem to figure out how to expose the richTextBox to append text to it. ...
1
by: GlobalDeveloper | last post by:
The following simple code which is supposed to enumerate the form and query variables does work in IE6 and FireFox but NOT in IE5. Could anyone advice me on this one??? I think the issue has to...
7
by: Mark Waser | last post by:
Hi all, I'm trying to post multipart/form-data to a web page but seem to have run into a wall. I'm familiar with RFC 1867 and have done this before (with AOLServer and Tcl) but just can't seem...
14
by: Professor Yonce | last post by:
I have made form for E-Mail. I have entered code but the Import system does not work. It has squiggly line underneath it showing it is not communicating. It Will not build. Public Class...
10
by: pythonnoob | last post by:
Hello everyone. New to python as well as this forum, but i must say ive learned a but already reading through some posts. Seems to be a pretty helpful community here. Before i post a question...
3
by: ibeehbk | last post by:
Hi. I have a form made in xhtml. I test via vbscript to make sure none of the fields are empty and properly formatted (ie email). All the regular fields work. However, I have two drop down menus...
1
omerbutt
by: omerbutt | last post by:
hi i am making a intranet online test application for a school and for that i have to make a form for creating the test the logic is to select a subject and then the number of questions for that test...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.