PHP array to MySql Database

I have a PHP array that gets the field names and the field values from one of my contact forms.

Here is the array:
foreach ($_POST as $key => $value)
{
if (!is_array($value))
{
$data .= “\n \n”.$key." : “.$value;
}
else
{
foreach ($_POST[$key] as $itemvalue)
{
$data .= “\n \n”.$key.” : ".$itemvalue;
}
}
}

Now I need to break out the VALUES to put into my SQL database. I
I am using MySQL for the database and I am not using all the values in the array to post to the database which is adding (at least for me a php noobie) some complexity to the problem. Obviously the id field id field is my index and is not in the array.

My Database table structure is like this:

id,
name,
address,
city,
state,
zip,
phone,
email,
arrivaldate,
depratdate,
room,
foundus,
promocode,
comments,
date,
ip

Just how How would I about this?

Thank you in advance

Dave

why are you creating one huge string? if you want to do it that way, explode data on /n/n then just do a normal insert using the various bits.

just curious as to why ur doing it this, kinda lends itself to some inaccuracies.

First of all you data table structure is crap if it is all lumped into the same table.

Second, why do an array to loop through the post values at all? Use your post values and load them into the database, using non deprecated code along with prepared statements.

Sponsor our Newsletter | Privacy Policy | Terms of Service