TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   User profile page (http://www.talkphp.com/general/2779-user-profile-page.html)

h0ly lag 05-08-2008 05:45 PM

User profile page
 
Ok, so I'm trying to code a user profile page. Pretty simple. All I need it to do is to get the user data, like username, maybe their email, join date. All the standard things. Anyways, the thing I'm having problems with is I need to select the row of the user by using $_GET. So my URL look like this "user.php?id=1". What I need to do is by using $_GET to find the user ID in the database then selecting that row and pulling the data I need from it. I'm having troubles selecting the row using the ID number. I'm not too MySQL savvy.

I have a column named `id`, `username`, and `email`. How do I select this by using the ID number and output it?

xenon 05-08-2008 07:07 PM

SQL is very simple if you look at it. You just need to get familiar with the basic commands. Your query might look like so:

Code:

SELECT * FROM profiles WHERE id=1
Of course, you would have to properly check the id before passing it to the database, but (hopefully), you now know what to do :)

h0ly lag 05-08-2008 08:53 PM

This is what I have already. Is there no reason why this shouldn't work?

"SELECT * FROM `user` WHERE id='$id'"

Where $id would be the ID number from $_GET.

EDIT: Aha... I needed to use mysql_fetch_array.


All times are GMT. The time now is 09:33 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0