azunoman Posted October 9, 2008 Share Posted October 9, 2008 Please excuse my rather novice question but I am at a point where I need the freaks direction on how to proceed. Have a cart...the cart has a productid with a variable number of accessories selected by the customer. Each of the fields required to define an accessory are the same. There can be 1-30 accessories... Looking for a the best approach in storing the variable number or accessories without having to have a unique mysql column name?...jajajaja...I find it somehow tacky (but will do it) to hard code a max number the col names in mysql for acc0,acc1,...as each accx has it's own information which would have to have a unique name also. I am considering just storing my cart array in a text field but I am somewhat worried about (un)serilization not working properly especially as my data can be in multiple languages. Thanks in advance you freaks! Please note in cart array that each acc is associated to a group but only the accID is really needed for the file. Nor does this cart show price etc. Here is a typical cart: [cart] => Array ( [PCOLOR] => Array ( [0] => 73 ) [TIRE] => Array ( [0] => 49 ) [CHRG] => Array ( [0] => 43 ) [bATT] => Array ( [0] => 39 ) [sEAT] => Array ( [0] => 23 ) [sEAC] => Array ( [0] => 68 ) [ARMPADOPT] => Array ( [0] => 66 ) [ARMS] => Array ( [0] => 13 ) [DCTL] => Array ( [0] => 4 ) [bASK] => Array ( [0] => 67 [1] => 61 [2] => 37 [3] => 52 [4] => 9 ) [OXYG] => Array ( [0] => 47 ) [PELV] => Array ( [0] => 55 ) [MISC] => Array ( [0] => 2 [1] => 28 [2] => 57 [3] => 62 [4] => 33 [5] => 45 [6] => 63 [7] => 1 [8] => 48 [9] => 46 ) [ProdID] => 49 [CartTime] => 1223587286 [ProdQty] => 1 Quote Link to comment https://forums.phpfreaks.com/topic/127767-variable-number-of-cols-for-a-record/ Share on other sites More sharing options...
Barand Posted October 11, 2008 Share Posted October 11, 2008 See sticky http://www.phpfreaks.com/forums/index.php/topic,126097.0.html You don't have a variable number of columns, you have a second table with a variable number of rows Quote Link to comment https://forums.phpfreaks.com/topic/127767-variable-number-of-cols-for-a-record/#findComment-662612 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.