Jump to content

Recommended Posts

Hi Everyone,

 

Is it possible to pass multiple variables in a URL? I'm my example below if you click on "Write A Review" I'm passing the #id variable but can you pass other variables in that URL?

 

http://whatsmyowncarworth.com/practiceTemplate/practice1/33/loans/table3.php

 

<?php
include('init.php');

/*$sql = "SELECT * FROM cars WHERE id='1' ORDER BY year ASC";*/

$sql = "SELECT * FROM dealers";
if ($result = mysql_query($sql)) {

echo "<table border='1'>";
echo "<tr> <th>ID</th> <th>Name</th> <th>Reviews</th> <th>Address</th> <th>State</th> <th>City</th> <th>Website</th> ";

// keeps getting the next row until there are no more to get
while ($row = mysql_fetch_array($result)){

$id = $row['id'];
$name = $row['name']; 
$address = $row['address'];
$state = $row['state'];
$city = $row['city'];
$website = $row['website'];
$maps = $row['maps'];
$lat = $row['lat'];
$lng = $row['lng'];


	echo("\t<tr>\n");
	/*echo("\t\t<td>" . "$id" . "</td>\n");*/
        /*echo("\t\t<td><a href='reviews2.php?id=" . $_GET['id'] . "'>" . "$id" . "</a>");*/
	/*echo("\t\t<td><a href='reviews2.php?$id='>" . "$id" . "</a>");*/
	/*echo "\t\t<td><a href='reviews2.php?$id'>$id</a>";*/
	echo "\t\t<td><a href='reviews2.php?id=$id'>$id</a>";
	/*echo("\t\t<td>" . "<a href='http://$website' target = '_blank'>" . "$name" . "</a></td>\n");*/
	echo("\t\t<td>" . "<a href='reviews2.php?id=$name'>$name ");
	echo("\t\t<td>" . "<a href='reviews2.php?id=$id'>Write Review ");
	echo("\t\t<td>" . "$address" . "</td>\n");
	echo("\t\t<td>" . "$state" . "</td>\n");
	echo("\t\t<td>" . "$city" . "</td>\n");
	echo("\t\t<td>" . "<a href='http://$website' target = '_blank'>" . "$name" . "</a></td>\n");
	/*echo 'Error reporting: ' . ini_get('error_reporting') . '<br>Display errors: ' . ini_get('display_errors');*/


}
echo "</table>";
}
else {
trigger_error(mysql_error()); // for development only; remove when in production
}
?>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">

  

</body>
</html>

Yes, you'd use the semicolon for this, so the URL would read this for example:

 

http://url.com?id=5;name=chris;function=example

 

etc.

 

Is this what you meant?

 

Semicolons are irregular as separators.  The ampersand is by far the most used method.

Yes, you'd use the semicolon for this, so the URL would read this for example:

 

http://url.com?id=5;name=chris;function=example

 

etc.

 

Is this what you meant?

 

Semicolons are irregular as separators.  The ampersand is by far the most used method.

 

Ahh okay, sorry for my misleading information. I've learned something here too :)

 

Thanks, pseud

Yes, you'd use the semicolon for this, so the URL would read this for example:

 

http://url.com?id=5;name=chris;function=example

 

etc.

 

Is this what you meant?

 

Semicolons are irregular as separators.  The ampersand is by far the most used method.

 

Ahh okay, sorry for my misleading information. I've learned something here too :)

 

Thanks, pseud

 

More info: http://en.wikipedia.org/wiki/Query_string

Be careful when you're using "&":

http://htmlhelp.com/tools/validator/problems.html

 

<!-- This is invalid! --> <a href="foo.cgi?chapter=1&section=2&copy=3&lang=en">...</a>

 

If you want to use "&" instead of "&", this url won't work in javascript:

 

http://jazzman.com?ajax=_1243564780&lang=EN	

 

You could use "&" in js, to wrap it up a CDATA code.

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.