Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: input form and MySQL across columns

by jandrew (Hermit)
on Sep 02, 2012 at 22:51 UTC ( #991335=note: print w/ replies, xml ) Need Help??


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.


Comment on Re: input form and MySQL across columns
Download Code
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://991335]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (16)
As of 2014-12-19 18:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (91 votes), past polls