czukoman20 Posted October 5, 2007 Share Posted October 5, 2007 First off. what type of variable would i use in a table for a database in mysql that can make a list. so that later on when i refer to it in php. then it will bring up a list of names. What i want to use this for is a user has a favorites column in the database. and when they click add user to favorites... it adds a name to the list in the database. or like an ID number. just so we can keep track of what users like what other users have. then after that is in the database. i would like to be able to refer to that list in a php document that lists all the users in the list. it sounds like a difficult process. but i just need a basic template as to how this works. i have no code written yet. or a datatable set up. so its up to you. please tell me if this is clear enough. it would be greatly appreciated Quote Link to comment https://forums.phpfreaks.com/topic/71892-solved-database-problems/ Share on other sites More sharing options...
trq Posted October 5, 2007 Share Posted October 5, 2007 Something like a buddy list? You don't actually store a list in one row, but have multiple rows. Create a table (buddies), with two fields (userid,buddyid). Then, everytime a user adds a buddy simply add a new record with there id and the buddies id. eg; INSERT INTO buddies (userid,buddyid) VALUES ('thorpe','bob'); INSERT INTO buddies (userid,buddyid) VALUES ('thorpe','foo'); INSERT INTO buddies (userid,buddyid) VALUES ('thorpe','bar'); This would add three buddies to my list of buddies. Now, to retrieve a list of my buddies, simply run... SELECT buddyid FROM buddies WHERE userid = 'thorpe'; hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/71892-solved-database-problems/#findComment-362145 Share on other sites More sharing options...
marcus Posted October 5, 2007 Share Posted October 5, 2007 What if you have no buddies -cough@thorpe- Quote Link to comment https://forums.phpfreaks.com/topic/71892-solved-database-problems/#findComment-362149 Share on other sites More sharing options...
trq Posted October 5, 2007 Share Posted October 5, 2007 DELETE FROM buddies WHERE userid = 'thorpe'; Quote Link to comment https://forums.phpfreaks.com/topic/71892-solved-database-problems/#findComment-362151 Share on other sites More sharing options...
czukoman20 Posted October 5, 2007 Author Share Posted October 5, 2007 Can you explain that a bit more. Like exactly what variables to use in the table when setting it up. and where to put these actual tables. because its and how does this go for more that 1 person doing this. will two people be in this datatable. im not getting as to how this works. Quote Link to comment https://forums.phpfreaks.com/topic/71892-solved-database-problems/#findComment-362160 Share on other sites More sharing options...
trq Posted October 5, 2007 Share Posted October 5, 2007 Read this post here as well, its exactly the same thing. And yes, of course you can have more than one user in the same table. Each record added relates a user with there buddy. Its quite simple. In the link I just gave there is an example of a add job link. Yours would be exactly the same but add buddy. Quote Link to comment https://forums.phpfreaks.com/topic/71892-solved-database-problems/#findComment-362173 Share on other sites More sharing options...
czukoman20 Posted October 5, 2007 Author Share Posted October 5, 2007 ok cool im sure i can figure it out with that information thanks Quote Link to comment https://forums.phpfreaks.com/topic/71892-solved-database-problems/#findComment-362176 Share on other sites More sharing options...
czukoman20 Posted October 10, 2007 Author Share Posted October 10, 2007 ok .... so now i have run into another issue INSERT INTO [u]buddies[/u] (userid,buddyid) VALUES ('thorpe','bob'); The buddies is the datatable right. Well i have a datatable setup like so http://www.czartgaming.com/testpages/help/database1.jpg http://www.czartgaming.com/testpages/help/database2.jpg Can you have me figure out how to guide the insert function to my database. and how i would have to setup the actual area where i put the information? Quote Link to comment https://forums.phpfreaks.com/topic/71892-solved-database-problems/#findComment-366605 Share on other sites More sharing options...
czukoman20 Posted October 11, 2007 Author Share Posted October 11, 2007 anyone?? Quote Link to comment https://forums.phpfreaks.com/topic/71892-solved-database-problems/#findComment-366618 Share on other sites More sharing options...
MadTechie Posted October 11, 2007 Share Posted October 11, 2007 i don't understand what your asking for! Quote Link to comment https://forums.phpfreaks.com/topic/71892-solved-database-problems/#findComment-366626 Share on other sites More sharing options...
czukoman20 Posted October 11, 2007 Author Share Posted October 11, 2007 ok .... so now i have run into another issue Code: INSERT INTO buddies (userid,buddyid) VALUES ('thorpe','bob'); oy i h8 bein a nuv.. ok well with that piece of code it directs the information to the buddies datatable in the mysql database How do i make it go into a sub-table. like buddies/buddyinfoo like the INSERT INTO buddies _______ (userid,buddyid) VALUES ('thorpe','bob'); im just confused as to pointing it where to go in the mysql db Quote Link to comment https://forums.phpfreaks.com/topic/71892-solved-database-problems/#findComment-366635 Share on other sites More sharing options...
MadTechie Posted October 11, 2007 Share Posted October 11, 2007 what! you want someone to tell you, your table name!! ??? Quote Link to comment https://forums.phpfreaks.com/topic/71892-solved-database-problems/#findComment-366638 Share on other sites More sharing options...
Cagecrawler Posted October 11, 2007 Share Posted October 11, 2007 You need to create a table called buddies. Use the following SQL or use phpMyAdmin: CREATE TABLE `dowmodsc_pico`.`buddies` ( `ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `userID` INT NOT NULL , `buddyID` INT NOT NULL ) ENGINE = InnoDB You can then insert buddies using the following SQL query: INSERT INTO buddies (userID,buddyID) VALUES ('1','2'); Where userID and buddyID relate to the relevant userid from the users table. Quote Link to comment https://forums.phpfreaks.com/topic/71892-solved-database-problems/#findComment-366639 Share on other sites More sharing options...
czukoman20 Posted October 11, 2007 Author Share Posted October 11, 2007 o ok lol sry for my noobyness lol ... and thanks Quote Link to comment https://forums.phpfreaks.com/topic/71892-solved-database-problems/#findComment-366650 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.