SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am developing a program that where to use it, people will have to register. I have a table in my database called users.

    What would be the best way to allow people to click on an icon, text, or whatever I choose, go to a favorites.php file, have them enter username/password, have the ID of the thing they wanted to add to their favorites, then add it to their row in the users table? Would I have to use commas to seperate them? If so, how could I parse it to display each thing that they have added to their favorites?

    Something like this...

    <a href="favorites.php?id=3&table=my_table">Add To Favorites</a>

    Thank you for all of your time, and God Bless
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  2. #2
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You'd just send the ID in the querystring to the favorites.php file - you seem to have it right in your example, what exactly is the problem? If you could go into more detail, I'd be glad to do what I can to help.

  3. #3
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    TWTCommish,

    Thanx for the offer, what I need to know is how to add the ID's to the users row... how would I retrieve them?

    I have two databases, each I want the user to be able to access, and add to favorites. So how is this possible? The reason I have to pass along the table variable in my example, is because I have to know which table that ID is from.

    What I am thinking is something like this......

    Code:
     ID |  Name   |  Password  |  Fav1  | Fav2
    -------------------------------------------------------
     1  |  Me     |  myself    | 1,5,6  | 3
    --------------------------------------------------------
     2  |  Foo    |  bear      | 9      |
    --------------------------------------------------------
     3  |  Another|  Example   | 5      | 9,8,6,2
    --------------------------------------------------------
    But, I'm not sure if this is the proper way, and if it is, how I would go about inserting that data into the database, retrieving it, or anything....

    Anything you could help me with would be helpful...

    God Bless, and thanx
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  4. #4
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A better way would be to create a new table - a basic principle of database design is that seperate "items" go in seperate tables.

    It'd be like this for the user's table:

    Code:
     ID |  Name   |  Password  | 
    -------------------------------------------------------
     1  |  Me     |  myself    | 
    --------------------------------------------------------
     2  |  Foo    |  bear      | 
    --------------------------------------------------------
     3  |  Another|  Example   | 
    --------------------------------------------------------
    And then like this for the favorites table:

    Code:
     ID |  Title  |  UserID | 
    -------------------------------------------------------
     1  |  Yup    |    1    | 
    --------------------------------------------------------
     2  |  Nope   |    1    | 
    --------------------------------------------------------
     3  |  Maybe  |    3    | 
    --------------------------------------------------------
    As you can see, in that table just above this text, there are three "favorites" entries - the first two are those "belonging" to user "Me" with the UserID of 1 - the last one belongs to "Another" - you link the two together through a unique ID in the user table.

  5. #5
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you very much, that will be put to work right away...

    I also have a question, when my tables get to millions of rows, which will happen on this site i'm working on, how much slower will my PHP be accessing it? Will there be much of a difference?

    Also, on the server I'm working on I'm given ONE database, how many tables will that hold? And how much data?

    God Bless, and thank you for your time and help.
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  6. #6
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's not really about the number of tables, just the amount of raw data. MySQL formerly supported something like 4GB of space (obviously that's quite a lot)...and I think it's gone up now to the point where MySQL can handle anything your server can.

    I would imagine more rows might slow things down a bit, but I don't think it would be serious at all - you'd be hard-pressed to populate enough rows to slow MySQL down significantly.


Bookmarks

Posting Permissions

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