473,549 Members | 2,741 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP Array to mySql Database

2 New Member
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 1429
Dormilich
8,658 Recognized Expert Moderator Expert
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
mranderson1137
2 New Member
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
2214
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. The problem is that we have many different file format (each company sends us it's own XML structure). How to provide a simple way to get those...
1
2537
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 transfer to a MySQL database. No special data, constraints etc that MySQL not will handle. My solution is to reverse engineer the database from...
7
1419
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 examples on the net to perform such a task? I have to think it's a pretty common application for passwording in PHP. thanks, Chris
1
3286
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 the next day, then break and display the third day, etc... Question:
2
4351
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 ONE field in each row gets a variable. The table name is RecentUploads, the field I want to pull is XML This is probably something simple that...
6
3080
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 to enter a password every time I want to edit a record. Is there a way to use our network login to do this? If not, what is the easiest way to...
12
1865
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 and there are links to the thumbnail list but also to the previous and next photo as the function remembers which position the photo has got in the...
7
16691
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 database is like this...
2
6295
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 = MySQLdb.connect(host="localhost", user="...", passwd="...", db="images") dbcurs = dbconn.cursor() dbcurs.execute("""SELECT imgdata FROM images LIMIT 1""")
5
2707
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 want to discuss in this post. Rather I would like to discuss the best way to program the following problem: I have a MySQL Database which for...
0
7520
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7450
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7957
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7470
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5368
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1059
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.