Jump to content

Inserting a complete array in a database field


Recommended Posts

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.

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.