Jump to content

quick newb php question


Drezek

Recommended Posts

Well, that depends. If you're getting it from a database you could do something like this:

 

$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
// or you could do:
$id = (int) filter_input(INPUT_GET, 'id', FILTER_UNSAFE_RAW)

$result = mysql_query('SELECT * FROM users WHERE id = ' . $id . ' LIMIT 1');

if (mysql_num_rows($result)) {
$user = mysql_fetch_assoc($result);
// do stuff
}
else {
echo 'User does not exist.';
}

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.