Jump to content

Recommended Posts

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)

Link to comment
https://forums.phpfreaks.com/topic/84866-mysql-php-and-lists/
Share on other sites

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';

Link to comment
https://forums.phpfreaks.com/topic/84866-mysql-php-and-lists/#findComment-432637
Share on other sites

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...

Link to comment
https://forums.phpfreaks.com/topic/84866-mysql-php-and-lists/#findComment-432644
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.