Jump to content

Dynamic URL's???


dzwestwindsor

Recommended Posts

Hello!

 

If you search Google, you'll notice the URL: http://www.google.com/webhp?hl=en#hl=en&source=hp&q=php+freaks&aq=f&aqi=g10&aql=&oq=&gs_rfai=CtdaTdtdRTNnPD5HuzASZtMWiCgAAAKoEBU_Q0ZT5&pbx=1&fp=19d754eee0b4f223

 

You can copy that URL anywhere you like... and the user will still see the same results.

 

So basically the URL dynamically does an action, and accesses the database.

 

How on do I make a URL like this? Meaning when you change the URL parameter values, it request a slightly different database query?

 

Does that make sense? Similarly with NexTag.com: http://www.nextag.com/serv/main/buyer/ProductCompare.jsp?search=camera&page=0&node=500001&psort=%2FDigital-Cameras--zzcameraz500001zB6z5---html&zipcode=&cptitle=657166355&cptitle=656751324&cptitle=620051906&cptitle=705150048

 

That was a Dynamically made URL (I selected from check boxes which products to compare) and it makes that URL so anyone can see those products.

 

Any ideas on how to do this?

 

 

More examples on the URL: http://www.cars.com/go/compare/modelCompare.jsp?myids=9721,11439  (i select the cars, it generates that URL. Notice the IDs 9721,11439)

 

Link to comment
Share on other sites

You would use the $_GET[] global. I will use a simplified google.com URL searching for "hello world" as an example.

 

like I said I have simplified the URL and removed all of the information Google uses for it's layouts.

 

note the part of the URL that is "q=" we are going to take the search terms from after that "hello+world".

 

http://www.google.com/#hl=en&source=hp&q=hello+world 

 

 

 

// get the serch tearms from the URL with $_GET[]
$searchterms = $_GET['q'];

// take the search terms and insert them into the database query
$query = "SELECT * FROM database WHERE something = '$searchterms'";

// database connection credentials
$dbc = mysqli_connect('databaseHost, username, password, databaseName');

// run the database query
$results = mysqli_connect($dbc, $query);

 

I think that is right there may be some errors but I think it gets the point across.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.