0

How would I make a code that dynamicly gets MySQL and makes it like ?UserID=54556 :-/?

4
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by johnmaguire2013
-1

[
$UserID = 54556;
$query = "select * from table where UserId = $UserID";
]

Votes + Comments
Did you see the like? =P
0

I saw

How would I make a code that dynamicly gets MySQL and makes it like ?UserID=54556 ?

You want to explain a bit more?

Maybe you want

select * from table where UserID like "%something%"
0

Make your url, e.g.: www.example.com/users.php?id=372687

Pick up the querystring 'id':

$id = mysql_real_escape_string($_GET['id']);

$rs = mysql_query("SELECT ... FROM ... WHERE id = '$id'");

...

Of course with this, you'd want to take two things in to account. First, the variable in double-quotes for the mysql_query() are a bit slower so you may want to do this instead:

$rs = mysql_query("SELECT ... FROM ... WHERE id = '" . $id . "'");

Also, since you are accepted a variable from the user, and throwing it into a SQL query, you'll want to test it for MySQL injection.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.