Forum Moderators: coopster

Message Too Old, No Replies

URL Parameter

Simple URL question

         

JoeyTheLips

8:40 am on Aug 30, 2007 (gmt 0)

10+ Year Member



Hi,

Can anyone help a newbie with something simple please? I've looked everywhere to no avail. I want a page to get a URL parameter to filter results. Here's what I have, the reference to the URL is missing:

$sSQL = "SELECT Name, Address, Telephone, Region FROM Table WHERE Region = 'URL'";
$result = mysql_query($sSQL) or print(mysql_error());

echo "<table border='1'>
<tr>
<th>Name</th>
<th>Address</th>
<th>Telephone</th>
</tr>";

while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Name'] . "</td>";
echo "<td>" . $row['Address'] . "</td>";
echo "<td>" . $row['Telephone'] . "</td>";
echo "</tr>";
}
echo "</table>";

Any help appreciated.

omoutop

9:14 am on Aug 30, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I assume you have something like: www.example.com/mypage.php?URL=mytext

On your page:
$URL = mysql_real_escape_string($_GET['URL']);

and then change your query to: WHERE Region = '$URL'

I hope this is what you want

Habtom

11:48 am on Aug 30, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To add up to omoutop just mentioned

Your values might be on the $_POST array too, depending on how they were posted.

You can just use REQUEST as well, and follow the recommendation above.

$URL = mysql_real_escape_string($_REQUEST['URL']);

. . . and yes, Welcome to WebmasterWorld

Habtom