Jump to content

[SOLVED] any suggestions??


nelquintin

Recommended Posts

I have developed a membership system with help from this site and many a like and all i would like to know if it better to have a database per user or should i use a table for each user. when the user logs in i just want to display his/her contacts that they have added to the database. i have a vague idea about sessions.

Link to comment
Share on other sites

i would recommend you do not use LIKE in your SQL query. you could run into problems if users have simliar usernames.

 

i.e. if a user has the username "andrew" and another users username is "andrews", when andrew logs in he will also see andrews contacts because of the likeness in usernames.

 

another feature i had was, when one user added another they had to be accepted by the user before he would be visible. i have a similiar table structure to how supermerc recommended, i just had another field "status" where i would change the value in the field to "verified" once the contact had been accepted. so when i (for example) added a contact the status field would be "pending" until the user i added accepted me as their contact.

 

here is the SQL Query i use:

SELECT * FROM `tablename` WHERE `username` = '$username' AND status = "verified";

 

This is to stop users from spamming other users by guessing usernames and sending messages to randomn people.

Link to comment
Share on other sites

ok now i have to write the contacts into the right table.so i tried

$result=mysql_query("INSERT INTO users WHERE username = '$username' (name, surname, birthday, mobile, office, home, email, maxprice, minprice, bed, gar) no luck also dont i have to specify the tablename which i would only know once they have signed in?

Link to comment
Share on other sites

i do know the structure of my database.Maybe i can try explain a bit better. When a user logs in i want him to retrive his contacts/client that he has submitted. i have a table called user and then i have tables for each of the user that will use this database. So how can i input the table name in

SELECT * FROM `tablename` WHERE `username` = '$username'  when i would only know what the tablename is according to who signs in?hope this helps.

Link to comment
Share on other sites

You should not be using a different table for each user period. That is just poor database design.

 

Look up some tutorial on database normalization, there is just no need for each user to have a specific table related to them.

Link to comment
Share on other sites

thank you now could you just help me with this line please

$result = mysql_query("SELECT name, surname, birthday, mobile, office, home, email, maxprice, minprice, bed, gar FROM client WHERE username = ".$_GET['username'])

or die("SELECT Error: ".mysql_error());

Link to comment
Share on other sites

$sql = "SELECT
                *
          FROM
                client
          WHERE
                username = '$user'";

$query = mysql_query($sql) OR die($sql . "<br />\nCaused the following error: ". mysql_error());

 

replace $user with something you KNOW is in the database under the column 'username'.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.