How to send two data in url on same parameter ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fhardi
Forum Newbie
Posts: 5
Joined: Mon Sep 02, 2013 4:05 am

How to send two data in url on same parameter ?

Post by fhardi »

Hi guys,

I'm new out here... :)
I need help to resolve something that I dont know how to do it.

My request is the following :
From a html Form, how to send two data in url on same parameter ?
I meant from the HTML Form, I have one drop down menu where I can select site or anything and a text field

So my question is how to send data from my drop down menu and data from test field ?
As such as :
&q={date from text field} {data from drop down menu}

In below my form :

Code: Select all

<form action="test.php" method="get">

<input type="hidden" name="cx" value="001921177962244596439:oqp21af-c3g" />
<input type="hidden" name="cof" value="FORID:9" />   
<input type="text" name="q" id="cse_search" class="cadr11FR" size="30" value=""/> Dans 
<select name="q">
  <option>Select...</option>
  <option>site:www.slamonline.com</option>
  <option>site:www.dimemag.com</option>
  <option>site:www.ncaa.com</option>
  <option>site:www.nfl.com</option>
  <option>site:www.nbcsports.com</option>
 <option>site:www.cbssports.com</option>
<option>site:espn.go.com</option>
<option>site:www.fiba.com</option>
<option>site:www.nba.com</option>
 <option>site:msn.foxsports.com</option>
 <option>site:www.themarsreel.com</option>
   <option>site:sports.yahoocom</option>
 </select>
 <input type="submit" value="Submit" />
</form>
I m looking for PHP instruction Or Javascript, more with PHP

Here my site test :
http://jeremy.lin.free.fr/test.php

Thank you guys for your help
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How to send two data in url on same parameter ?

Post by Celauran »

Don't reuse names.

Code: Select all

www.yoursite.com/?a=foo&b=bar
fhardi
Forum Newbie
Posts: 5
Joined: Mon Sep 02, 2013 4:05 am

Re: How to send two data in url on same parameter ?

Post by fhardi »

Celauran wrote:Don't reuse names.

Code: Select all

www.yoursite.com/?a=foo&b=bar
Hi Celauran,

thnx for your reply but this happenedin form in a form ,I need to send 2 data in same parameter &q=[1] [2]

Because what I want is to search a word on spcific site, and also I use google custum search, and Google required if you want to search only on one site it looks like this :
Example if I search javascript site:http://forums.devnetwork.net on google , only the the word "javascript" will be found in result on http://forums.devnetwork.net
On google url :

Code: Select all

 https://www.google.com/#q=javascript site:http://forums.devnetwork.net
So on my test site it looks like this :

Code: Select all

test.php?cx=001921177962244596439:oqp21af-c3g&cof=FORID:9&q=Jordan&q=site:www.nba.com
And I would like the parameter q= contains Jordan and site:www.nba.com
As such as :

Code: Select all

test.php?cx=001921177962244596439:oqp21af-c3g&cof=FORID:9&q=Jordan site:www.nba.com
Online it looks like this http://jeremy.lin.free.fr/test.php?cx=0 ... ww.nba.com

Thanks again for your help
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How to send two data in url on same parameter ?

Post by Celauran »

Oh, I see what you're saying. You want to use a +

Code: Select all

q=Jordan+site:nba.com
You could have figured this out by simply Googling the search string and looking at the resulting URL.
fhardi
Forum Newbie
Posts: 5
Joined: Mon Sep 02, 2013 4:05 am

Re: How to send two data in url on same parameter ?

Post by fhardi »

Celauran wrote:Oh, I see what you're saying. You want to use a +

Code: Select all

q=Jordan+site:nba.com
You could have figured this out by simply Googling the search string and looking at the resulting URL.
Hi Celauran

Yes similar, I added "+" between Jordan and site:www.nba.com and the result is same...

Could you help me to write an instruction in PHP to set this up ?
I don't know where to start

Thnx
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: How to send two data in url on same parameter ?

Post by AbraCadaver »

You're not going to be able to do this in PHP with a form. You will need JavaScript.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
fhardi
Forum Newbie
Posts: 5
Joined: Mon Sep 02, 2013 4:05 am

Re: How to send two data in url on same parameter ?

Post by fhardi »

AbraCadaver wrote:You're not going to be able to do this in PHP with a form. You will need JavaScript.
Hi AbraCadaver

Oh really I though we can do it in PHP using variable
Could you give me an example ?

Thnx
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: How to send two data in url on same parameter ?

Post by AbraCadaver »

It depends. You either want to pass data from your form and receive it somewhere, which we can do, or you want the URL to look a certain way. Must the URL look like that or what?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
fhardi
Forum Newbie
Posts: 5
Joined: Mon Sep 02, 2013 4:05 am

Re: How to send two data in url on same parameter ?

Post by fhardi »

Yes I want to pass data from the form and the URL have to look like this way :

Code: Select all

test.php?cx=001921177962244596439:oqp21af-c3g&cof=FORID:9&q=Jordan+site:www.nba.com
Post Reply