saeed_violinist Posted May 15, 2007 Share Posted May 15, 2007 Hi, I have a very big signup form and it is almost impossible to create a full table for it because of very high number of form fields and I dont want to create a field for each of them in my database's table. but I managed to store all the form values in an array, is there a way to fully insert an array to just one field? and for future use select it again as an array? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/51446-inserting-a-complete-array-in-a-database-field/ Share on other sites More sharing options...
radar Posted May 15, 2007 Share Posted May 15, 2007 The answer is no, in order to do this you would need to create a field for each one in your database... It'll be the easiest way to do it for future programming. My registration is quite extensive as well, and my users table in my database has 110 different things it could have in it.. the only way for future programming would be to do it that way as well.... also i'd make a functions.php to keep all of your functions in, and keep your insert statement in functions.php and just call it when you need it.. here is the way i write functions that may help you to write functions easier to read... <?php function insert_aact($userdata, $page, $action, $id, $crev, $old) { $sql = "INSERT INTO z_".$page." SET about_txt = '".$old[about_txt]."', last_edited = '".$old[last_edited]."'"; mysql_query($sql); $id = mysql_insert_id(); $sql = "INSERT INTO adminact SET aact_admin = '".$userdata[admin][username]."', aact_crev = '$crev', aact_itemid = '$id', aact_page = '$page', aact_action = '$action', aact_ip = '$userdata[_ip]', aact_date = now()"; mysql_query($sql); } ?> However since all of your stuff is in an array you could put in only like say $data in the function, and then use like username = '$data[username]', password = '$data[password]', and so on to the end... Quote Link to comment https://forums.phpfreaks.com/topic/51446-inserting-a-complete-array-in-a-database-field/#findComment-253369 Share on other sites More sharing options...
saeed_violinist Posted May 15, 2007 Author Share Posted May 15, 2007 omg! ... I have over 200 fields and some of my fields are also divided in smaller fields. coud you explain your idea a bit more please? Quote Link to comment https://forums.phpfreaks.com/topic/51446-inserting-a-complete-array-in-a-database-field/#findComment-253449 Share on other sites More sharing options...
jitesh Posted May 15, 2007 Share Posted May 15, 2007 Post your array here by ... echo "<pre>"; print_r($your_array); Quote Link to comment https://forums.phpfreaks.com/topic/51446-inserting-a-complete-array-in-a-database-field/#findComment-253451 Share on other sites More sharing options...
saeed_violinist Posted May 15, 2007 Author Share Posted May 15, 2007 wow my array is really big, by the way its not a multi dimentional array but a really big array. are you sure there is no way to store an array in a table's field? Quote Link to comment https://forums.phpfreaks.com/topic/51446-inserting-a-complete-array-in-a-database-field/#findComment-253924 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.