473,396 Members | 1,765 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,396 software developers and data experts.

insert php array into mysql

I have an array $product_array, and when I use print_r($product_array);. The array shows like this

Expand|Select|Wrap|Line Numbers
  1. Array ( 
  2.  
  3. [0] => Array 
  4.     ( 
  5.        [ID] => P00100 
  6.        [NAME] => Edina 
  7.        [PRICE] => $20.00 )
  8.  
  9. [1] => Array 
  10.     ( 
  11.         [ID] => P00101 
  12.         [NAME] => Richfield 
  13.         [PRICE] => $21.00 
  14.     ) 
  15.  
  16. [2] => Array 
  17.     ( 
  18.         [ID] => P00102 
  19.         [NAME] => Bloomington 
  20.         [PRICE] => $22.00 
  21.     ) 
I created my database table in 4 columes, first one is mainid, and which is auto increment, following with ID, NAME, PRICE, as the keys showed above. I would like to insert this array $product_array into mysql. Can anyone help? Would be very much appreciated! tks.
Oct 24 '10 #1
1 2523
bob2044
16
Expand|Select|Wrap|Line Numbers
  1. foreach($prdouct_array as $val){
  2. mysql_query("insert into tbl(name,price) values)($val['name'],$val['price']); 
  3. }
Oct 25 '10 #2

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

Similar topics

1
by: Phil Powell | last post by:
I have to get this done by tonight! I have a .CSV file and a PHP file where I am inserting the values of the CSV file into the db table. See the results live:...
2
by: Atz | last post by:
Hi to all ! Im using MySql front and PHP 5 for some web shop. I didn't try it so far but i guess that the online data insertation ( accept costs and time ) should be the same process like for...
8
by: Johannes A. Brunner | last post by:
Got a simple problem. I code some site and because Im a freak I made my own session-handling. When a user open up my site it will check if there is a ssid in the url if not generate one. this will...
3
by: Materialised | last post by:
Hello everyone, I am having a issue inserting values into a MYSQL table, and for the life of me, I can figure out why. I know the connection is successful, however I am getting errors. The...
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: sanjeevcis | last post by:
Hi, Below code is regarding to insert an array values into mysql db using php. i dont know why the code is not inserting array values into database properly. If is there any thing wrong with the...
5
by: radhak | last post by:
how to insert array?using php mysql
3
by: Waruna | last post by:
Is there a way to block insert into mysql(5.0) using c api of mysql db.. i.e. say there is a table with 2 columns, one contains char other int then i want to insert 500 records at once,, as i...
1
by: abhishek1234321 | last post by:
mysql_query("CREATE TABLE $value (Subject VARCHAR(200), External int(3))"); preg_match_all('/<i>(.*?)<\/i>/si', $matches, $submatch, PREG_SET_ORDER); mysql_query("INSERT INTO $value (Subject)...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.