what do you call "dynamic URLs" ?
urls with parameters ? urls generated on the fly ? how and why ?
Main Topics
Browse All Topicscould anyone tell me please? do i need to use mysql for dynamic urls... this isnt that urgent, but it would be cool to have em!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
yes, okay, URIs with parameters.
something like this will do it and you don't need MySql
<?php
$somevar="somewhere who told me this";
$theuri="http://somedomain
echo "<a href=\"$theuri\" target="_new">click here to go $somevar</A>";
?>
on the receiving end :
$_GET['somevar'] and $_GET['otherone'] will contain the passed values
I hope this helps
Okay, well say you had a MySQL table called "users" that looked like this:
+---------+-----------+---
| user_id | user_name | user_pass | user_email |
+---------+-----------+---
| 1 | bork | bork | bork@blahblah.net |
| 2 | bink | bink | bink@bleeblee.net |
+---------+-----------+---
And you wanted to make a set of links that would go off to everyone's profile information or whatever:
--------------------------
<?php
// Connect to MySQL
// Note: replace localhost, username, password, and database with your own values
mysql_connect('localhost',
mysql_select_db('database'
// Get everything from the users table
$query = "select * from users";
// Query the database
$result = mysql_query($query) or die("Problem with the query: " . mysql_error());
// Loop through each row and make a URL for each row
while ($row = mysql_fetch_assoc($result)
extract($row);
echo("<a href=\"view_details.php?us
}
// close database connection
mysql_close();
?>
--------------------------
Your code, once displayed, would look like this:
<a href="view_details.php?use
<a href="view_details.php?use
Then view_details.php would act based on the ID that was passed to it:
--------------------------
<?php
// Connect to the database again
mysql_connect('localhost',
mysql_select_db('database'
// Create variables for all the passed querystring information
extract($_GET);
// Get details for the specific user that was chosen
$query = "select * from users where user_id = $user_id";
// Query the database
$result = mysql_query($query) or die("Problem with the query: " . mysql_error());
// Grab the returned row
$row = mysql_fetch_assoc($result)
extract($row);
// Display results to the screen
echo "
<h2>User details</h2>
Username: $user_name<br>
E-mail: $user_email<br>
";
// Close database connection
mysql_close();
?>
--------------------------
So for example, if you selected the first link, it would show you username bork and email address bork@blahblah.net.
Hope that helps...
blah.php?firstname=sam&las
The "?" is used to indicate the beginning of the GET arguments.
The "&" is used to separate the key=value pairs from each other
All the keys and values should be passed through urlencode() function to convert spaces, ampersands, equals signs, etc.
Try making a page called "blah.php" which contains the following code:
<?php print_r($_GLOBALS); ?>
Then access the page with the URL above.
you will see how the arguments in the URL are available to the PHP code, through the $_GET['firstname'] or $HTTP_GET_VARS['firstname'
excuse-me, but if you copy-paste this very first "answer", it works... Comment from VGR Date: 07/09/2003 05:43AM PDT
<?php
//
// file blah.php
//
if (isset($_GET)) {
if (isset($_GET['somevar'])) {
echo "the variables receoved were : somevar={$_GET['somevar']}
} // if CORRECT data received
} // if data received
$somevar="somewhere who told me this";
$theuri="blah.php?somevar=
echo "<a href=\"$theuri\" target="_new">click here to go $somevar</A>";
?>
Business Accounts
Answer for Membership
by: snarkadorPosted on 2003-07-09 at 05:05:35ID: 8884521
Hm. Could you be more specific?
atthing=th is
Do you mean dynamic as in ever changing, like a random link generator retrieving URLs from a MySQL database?
Or do you mean URLs with querystring variables after them that change, such as:
blah.php?thisthing=that&th
And then have the values that are passed interact with MySQL?
Would be helpful to know what table structure you're working with as well, if possible.