Skip site navigation (1) Skip section navigation (2)

Re: Stroring html form settings

From: Marcus Engene <mengpg2(at)engene(dot)se>
To: Dianne Yumul <dianne(at)wellsgaming(dot)com>
Cc: PostgreSQL List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Stroring html form settings
Date: 2008-09-26 09:02:01
Message-ID: 48DCA509.2060002@engene.se (view raw or flat)
Thread:
Lists: pgsql-general
Dianne Yumul wrote:
> Hello,
>
> I have some html forms that I save the settings into the database, 
> things like which item was selected in the menu and if a checkbox was 
> checked. The table looks like this:
>
>  user_id | report_id |                      info
> ---------+-----------+------------------------------------------------
>      111 |         1 | A:::::CHECKED::::CHECKED::::CHECKED::
>      111 |         2 | A:::CHECKED::
>      111 |         3 | A::CHECKED:CHECKED::CHECKED::::CHECKED:::
>
> The info column has the settings separated with a : and consecutive 
> colons mean the user didn't make a selection. Would this be the way to 
> store them?
>
> I've done some searching and I could use XML (I will read some 
> tutorials after writing this email). But there may be other ways and 
> I'm just too much of a newbie to know. I'm using Postgresql 8.1.11 and 
> PHP on CentOS 5.2.
>
> Thanks in advance.
>
> Dianne
>
Hi,

I would serialize to JSON instead of XML.
http://www.aurore.net/projects/php-json/

A simple json_encode($_POST) might do the trick. You could either use 
json_decode() to make a PHP struct of it or send it more or less as it 
is to Javascript.

I usually find XML horrible to work with in a web context.

Best regards,
Marcus


In response to

pgsql-general by date

Next:From: Pavel StehuleDate: 2008-09-26 12:11:16
Subject: Re: Dynamically created cursors vanish in PLPgSQL
Previous:From: Reg Me PleaseDate: 2008-09-26 08:31:07
Subject: Re: Dynamically created cursors vanish in PLPgSQL

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group