|
Posted by David Haynes on 02/05/06 17:12
Jim S. wrote:
> 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
Jim,
I really wonder why you are going to all this trouble to code stuff that
is so easily modeled in the database. Is there some really compelling
reason not to use the power of the database to do your work for you?
Consider the following:
1. a table that contains a code number and a text field (lets call it codes)
2. a table that holds the non-dynamic stuff around your array. At a
minimum it has a unique id column and a description column. (lets call
it main)
3. a table that contains the unique id from the main table and a code
number from the codes table for each option in the array (lets call it
options)
Now, you can do things like:
select codes.description
from codes, options, main
where codes.code_number = options.code_number
and options.unique_id = main.unique_id
and main.unique_id = $unique_id;
to get all the selection options (as text) for an entry in your main table.
If you just wanted the code numbers, you could use:
select options.code_number
from options, main
where options.unique_id = main.unique_id
and main.unique_id = $unique_id
order by options.code_number;
for a sorted list.
-david-
Navigation:
[Reply to this message]
|