PHP使用页面名称作为变量[关闭]

What I would like to do is say someone comes to my site and goes to

www.site.com/users/james

The page /james won't exist so I want to take the name james and use it to then display a profile page based on that user name i.e use james in a search to pull back info from my DB.

What would be the best way to do this?

.htaccess

RewriteEngine on
RewriteRule ^/users/(.+?) /users.php?name=$1

users.php

<?php
if ($_GET['name']) {
    $query = mysql_query("SELECT * FROM `users` WHERE `name`='".mysql_real_escape_string($_GET['name'])."'");
    if (mysql_num_rows($query)>0) {
         $user = mysql_fetch_assoc($query);
         print_r($user);
    }
}