aran Posted January 7, 2008 Share Posted January 7, 2008 I was wondering what is the best way to store a list within MySQL and then output it using PHP. Basically should I be storing my lists in a format similar to : apple orange banana Or should it be divided up with something in between the list elements : apple,orange,banana And then as well how will I be able to count each list item and then count them and do what ever with them later on... Display the list items showing how many times its been used and on what it has been used with... (Basically a tag system) Quote Link to comment https://forums.phpfreaks.com/topic/84866-mysql-php-and-lists/ Share on other sites More sharing options...
trq Posted January 7, 2008 Share Posted January 7, 2008 You would have a simple table structure something like. CREATE TABLE list ( id INT AUTO INCREMENT, item VARCHAR(80), amount INT ); Then add items to the list... INSERT INTO list (item) VALUES ('apple'); INSERT INTO list (item) VALUES ('orange'); INSERT INTO list (item) VALUES ('banana'); Then to increase the amount an item was used. UPDATE list SET amount+1 WHERE item = 'apple'; Quote Link to comment https://forums.phpfreaks.com/topic/84866-mysql-php-and-lists/#findComment-432637 Share on other sites More sharing options...
aran Posted January 7, 2008 Author Share Posted January 7, 2008 The list is not going to be set and is put into a news table. It is a entity of the table I have set it to text at the moment... (Think this is right way) Basically the system is going to be tags for news but I want PHP to count how many times its been used for later use... Such uses like stats / browsing / searching ... Things like that. Sorry if am not totally clear not usually my strong point it getting the message clear first time... Quote Link to comment https://forums.phpfreaks.com/topic/84866-mysql-php-and-lists/#findComment-432644 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.