Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-20-2012, 12:18 AM   PM User | #1
HighFive
New to the CF scene

 
Join Date: Apr 2012
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
HighFive is an unknown quantity at this point
Question Creating Profiles for Existing Users

Hello all! I'm extremely new to coding with a database, and php, and would appreciate some help.
My site currently has a database and members, but used an installer and, basically, I didn't have to do much. But now I want to push it and add many more things to the website.

Currently I'd like to take all of the users and give them a profile of sorts.
Ex: www.sitename.com/bio/userhere
I would like to know if there's an easier way to do this for existing members rather than to create all directories manually.
I have many more questions, such as how to allot said directories to members upon sign up, but don't think they belong on this board.
If I should redirect my questions to the php board, tell me and I'll get that straightened out.

Sorry for my ignorance on all of this, I'm just not sure on where to begin.
Thanks for any help!
HighFive is offline   Reply With Quote
Old 04-20-2012, 12:37 AM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,210
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Pardon me, but your request is just wrong-headed.

You don't want to create *ANY* directories.

You want to detect the URL and *DYNAMICALLY* generate the content, based on your database values.

To get started, try something like http://www.sitename.com/bio.php?user=old+pedant

Now your bio.php code can do
Code:
<?php
... make your DB connection ...

$user = $_GET["user"];
$sql = "SELECT * FROM user_information WHERE username='" . $user . "'";
$result = mysql_query($sql);
... now display data from the record (if any!) about that user ...
So you have *ONE* PHP page that generates bios for all members, on the fly.

[That code has some flaws in it...it was only for purposes of example.]

*LATER*, if you want to, you can learn how to use mod rewrite rules that will automatically convert, say, www.sitename.com/bio/johnboy to the (hidden) URL www.sitename.com/bio.php?user=johnboy so it *looks* like you have a directory per user all the while everything is done by one PHP page.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.

Last edited by Old Pedant; 04-20-2012 at 01:01 AM..
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
HighFive (04-20-2012)
Old 04-20-2012, 12:50 AM   PM User | #3
HighFive
New to the CF scene

 
Join Date: Apr 2012
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
HighFive is an unknown quantity at this point
Thanks for the explanation!
I'm really new to this so I'm basically in the dark to it all.
I'll do as you say and see what I can figure out, if I have more questions I'll be sure to ask.
Thanks again.
HighFive is offline   Reply With Quote
Old 04-20-2012, 01:00 AM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,210
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
If you show your database schema (names of tables and names and type of fields in each table) we can probably help you more with the SQL query or queries you would need.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Tags
existing, profile, profiles, user, users

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:51 PM.


Advertisement
Log in to turn off these ads.