You are here: Re: an array to a database, am having hard time , help!! « PHP Programming Language « IT news, forums, messages
Re: an array to a database, am having hard time , help!!

Posted by Jim S. on 02/05/06 16:35

well i got lastly, a variable that is like: $mystuff and has 1,4,3,6,7,8

but i am not able to put $mystuff in the table no matter what i do.
my table field is of a type Varchar(255) .

now let us assume that i succeed (am being Very optimistic, emphasic on
VERY)
i know i can use explode, but i want to change the 1,4,3,6,7,8 to the
option that i started with. so how can i do that?
so i can have instead of numbers, basically, to have option1, option4,
option3, ... and so on.

helllllllllllllp :D
<xclarky@gmail.com> wrote in message
news:1139144662.354557.102930@f14g2000cwb.googlegroups.com...
> ENUM is basically the same as SET however it allows NULL values.
> Therefore this would be a wrong data type to use considering what you
> are storing. Both basically set up a list of acceptable values for the
> field.
>
> As you are storing an array, I would advise you to convert it to a
> string so you have a list of numbers, separated by a divider; as you
> have done.
>
> You can then store that list in your field, VARCHAR or TEXT should be
> appropriate depending on the length of the list.
>
> When retrieving the data you can use explode() or array_map() to create
> an array of the numbers for whatever purpose you wish. Alternatively
> you can use MySQL functions in the WHERE clause for statements if you
> are looking to perform a action where a match is found for a specific
> value in your list.
>
> Hope that helps you.
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация