473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

PHP Array to mySql Database

OK guys:

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

Expand|Select|Wrap|Line Numbers
  1. foreach ($_POST as $key => $value)
  2. {
  3.     if (!is_array($value))
  4.     {
  5.         $data .= "\n \n".$key." : ".$value;
  6.     }
  7.     else
  8.     {
  9.         foreach ($_POST[$key] as $itemvalue)
  10.         {
  11.             $data .= "\n \n".$key." : ".$itemvalue;
  12.         }
  13.     }
  14. }
Now I need to break out the values to put into my SQL database.

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 in the database is my index and is not in the array.

The MySql database table structure looks like this:

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

Just how would I go about this?
Aug 14 '14 #1
2 1424
Dormilich
8,658 Expert Mod 8TB
Obviously the id field in the database is my index and is not in the array.
if it’s set to AUTO_INCREMENT it will be automatically set and you don’t need to pass it.
Aug 14 '14 #2
Yes I know about the ID field that was just comment so folks would not have to worry about pulling that out of the array. I need to know how to break the array apart to get the values of the array into my database.
Aug 14 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Bob Bedford | last post by:
Where to find a comprehensive document on how take datas from XML and put them in a Mysql Database. I've many sites sending us XML files. We have to parse datas and save those datas on Mysql. ...
1
by: Cern | last post by:
Is it somebody out there who has made a migration from an Oracle server to an MySQL server?? The scenario is as simply: I've got a Oracle 8 server with a database with content that I want to...
7
by: Chris | last post by:
I have a PHP query for a MySQL database that I'd like to restrict access to. It's linked from a .htm webpage with other links on a company intranet site. Does anyone know of any PHP code...
1
by: pizzy | last post by:
Problem: I am trying to develope my personal site to select from my mysql database and organize data on the page so that it will display all the submissions for that day, then break and display...
2
by: ameshkin | last post by:
I know this is probably not too hard to do, but how do I display multiple rows of a mysql query/recordset. Im having trouble doing this. I don't just want to display them, but I want to make sure...
6
by: Bob Sanderson | last post by:
I have created a MySQL database for my company which is accessed by PHP pages. I would like to permit some users to edit the records but allow others read-only access. However, I don't want to have...
12
by: Martien van Wanrooij | last post by:
I have been using for a while a class to create photo albums. Shortly, an array of photo's is declared, initially they are shown as thumbnails, by clicking on a thumbnail a larger photo is shown...
7
by: asenthil | last post by:
Hai to all, this is senthil... i'm now working in the field of VC++... i want to connect a mysql database... just now tried to retrieve rows from a simple mysql database by using VC++ My...
2
by: Christoph Krammer | last post by:
Hello, I try to write a python application with wx that shows images from a MySQL database. I use the following code to connect and get data when some event was triggered: dbconn =...
5
by: Marijn | last post by:
Hello everybody, I am new to PHP and working on extending my knowledge of OOP. The posts in this group concerned with whether or not to use an OO approach when programming in PHP is not what I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.