how do i write something which will let me search registered users on my site? also how do i make a page, tht is the profile, which will output data according to the user id??
searching users
You can use a $_GET variable for the userid and search for that id in the database. I'll write something if you'd like that.
| riyadh wrote: |
| how do i write something which will let me search registered users on my site? also how do i make a page, tht is the profile, which will output data according to the user id?? |
Depending on your database, you could do a MySQL query selecting the fields from the table and you echoing it out on your page. It can be simply done.
Assuming the table structure below
You can do a query
| Code: |
| Users
------------------------------------------------------------- | id | name | password | regdate | status | etc ...| ------------------------------------------------------------- |
You can do a query
| Code: |
| "SELECT name, regdate, status FROM Users WHERE id='$id'"
|
| kv wrote: | ||||
Assuming the table structure below
You can do a query
|
With that you can make something like this:
| Code: |
|
if (isset($_GET['id'])) { $id = (int) $_GET['id']; $link = mysql_connect('localhost', 'username', 'password') //change the pass and username or die('Could not connect: ' . mysql_error()); mysql_select_db('database') or die('Could not select database'); //change the database $query = "SELECT name, regdate, status FROM Users WHERE id='$id' LIMIT 1"; $result = mysql_query($query) $user = mysql_fetch_array( $result ); echo 'username: '. $user['nick'] .'<br />Registered since: '. $user['regdate']; } else { echo "No userid given"; } ?> |
