Jump to content

MySQL, PHP and Lists


aran

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

Archived

This topic is now archived and is closed to further replies.

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