TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-08-2008, 05:45 PM   #1 (permalink)
The Contributor
 
Join Date: Apr 2008
Location: Nevada, USA
Posts: 52
Thanks: 10
h0ly lag is on a distinguished road
Default 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?
Send a message via AIM to h0ly lag Send a message via MSN to h0ly lag
h0ly lag is offline  
Reply With Quote
Old 05-08-2008, 07:07 PM   #2 (permalink)
The Frequenter
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 440
Thanks: 3
xenon is on a distinguished road
Default

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 :)
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 05-08-2008, 08:53 PM   #3 (permalink)
The Contributor
 
Join Date: Apr 2008
Location: Nevada, USA
Posts: 52
Thanks: 10
h0ly lag is on a distinguished road
Default

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.

Last edited by h0ly lag : 05-09-2008 at 02:03 AM.
Send a message via AIM to h0ly lag Send a message via MSN to h0ly lag
h0ly lag is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 05:54 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design