http://www.perlmonks.org?node_id=991335


in reply to input form and MySQL across columns

I'm not entirely sure I follow your problem but I would say that the issue seems to fall in the set up of your MySQL table

The columns qty1, qty2, qty3, and qty4 break the Repeating groups across columns restriction of the "first normal form" of relational data bases

If you accept that this is the problem the fix would be a table that looked something like

ID type name qty_position qty status 1 Group1 Shoes 1 15 ok 2 Group1 Shoes 2 50 ok

This solution gets you back to a query with return values in one column. You just have to use conditions on more than one column to SELECT the right data.

A word of warning - distributing the status column across all of the rows effectively breaks another of the normal form rules. To fix it you would move that value to a separate table. However, If the status is defined at the point of the transaction for each quantity increment then you are fixing something rather than breaking it.

Replies are listed 'Best First'.
Re^2: input form and MySQL across columns
by Anonymous Monk on Sep 03, 2012 at 00:51 UTC
    Thanks for the reply, I agree the table should probably have been structured in a single column right from the beginning. I was hoping to come up with a solution without having to go down that path. And good point on the status column as well. I'll wait until the other Monks reply before I redo the table, I have quite a bit of code already written for inserting and updating the table that works quite well.