faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 1 people (100%) answered Yes
Recently 1 of 1 people (100%) answered Yes

Entry

How can i add all the values of a form in one field in a table using array

Mar 28th, 2008 16:29
ha mo, Viju,


//This program is for inserting ALL THE  VALUES IN THE SAME FIELD  IN AN
ARRAY FORMAT.  
if($errors>0)//This is for checking  any errors in the form
{
  foreach($error_fields as $field)//The errors are storing
in$error_fields array
  {
   //Assigning the values of error_field array as the key elements of
the error_compare array. PURPOSE: To compare with the exisiting array in
the DB + unsetting the variables not needed for insertion. 
    $error_compare[$field]=array();
 } 
//Here I am unsetting unwanted values from the error_fields array
unset($error_compare['scheme'],$error_compare['password'],$error_compare['password1']);
// begin Recordset Here only two fields are there one value I gave as HL
(just a value)
$query_home_error = "SELECT * FROM home_error";
$home_error = $realestate->SelectLimit($query_home_error) or
die($realestate->ErrorMsg());
$totalRows_home_error = $home_error->RecordCount();
// end Recordset
//Fetching array from DB in array format using unserialze function
$db_errors=unserialize($home_error->Fields('error'));
foreach($error_compare as $key=>$value)
{
	$value=$_REQUEST[$key]; //Requested values from the form
	if(array_key_exists($key,$db_errors))
	{
		array_push($db_errors[$key],$value);
	}
	else
	{
		$db_errors[$key]=array();
		array_push($db_errors[$key],$value);
	}
}
	  $db_errors=serialize($db_errors);
mysql_query("UPDATE home_error SET error='".$db_errors."' WHERE type='HL'");
  }
http://www.tantofa.com
http://www.fantofa.com
http://www.mantofa.com
http://www.tanpola.com
http://www.tampola.com
http://www.yamot.com
http://www.mozmar.com
http://www.templatestemp.com