Re: multiple entries in the same field

From: Date: Wed, 04 Jul 2001 10:18:34 +0000
Subject: Re: multiple entries in the same field
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-56152@lists.php.net to get a copy of this message
Hi Jamie, use explode() or split(), these will split up your string eand return the resulting elements as an array. Generally speaking its not reaally good practice to store multiple entries as a comma sepparated string in one db field, since it takes down the data integrity of your database. Better would be to just store them in three sepperate columns in your table. If the number of items is not always the same, you should store these as individual entries in a sepperate table with the primary key of your original table. This way you can use the full potential of your database. My humble opinion though, Wieger Jamie Saunders wrote: > > Hi, > > In a MySQL database I have one field that holds several entries seperated by > a comma (e.g. item1,item2,item3). What I want to do is to get these items > from the db from a PHP script and display each item on it's own line (e.g. > item1<br>item2<br>item3). Is there anyway of doing this easily by simply > changing each comma to a '<br>' in the script? > > Thanks. > > Jamie Saunders > jamie.s@btinternet.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net -- Wieger Uffink tel: +31 20 428 6868 fax: +31 20 470 6905 web: http://www.usmedia.nl

« previous php.general (#56152) next »