Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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!

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,103
    Thanks
    80
    Thanked 4,554 Times in 4,518 Posts
    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.
    Last edited by Old Pedant; 04-20-2012 at 02:01 AM.
    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.

  • Users who have thanked Old Pedant for this post:

    HighFive (04-20-2012)

  • #3
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,103
    Thanks
    80
    Thanked 4,554 Times in 4,518 Posts
    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.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •