Jump to content

Can you pass multiple $variables in a URL?


Guest

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.