Jump to content

Inserting multiple items to the database from an array


6pandn21

Recommended Posts

Hello everyone,

 

I am building a simple shopping cart but my knowledge is somewhat limited in this area. So I have a query string for storing three different data; items_name, amount and price.

 

$name_items_query_string .= '&item_name_' . $database_count . '=' . $item['name'];
		$price_items_query_string .= '&amount_' . $database_count . '=' . $item['price'];
		$qty_items_query_string .= '&quantity_' . $database_count . '=' . $item['qty'];

 

So these string contains multiple items which I need to insert to my database table but I really have no knowledge unfortunately. I am thinking maybe I will need to explode the array and store them as comma separated file but that's just a shot in the dark. If anyone could show me some directions; like a tutorial or an example, it would be great. Thank you.

I don't quite understand. Can you post up a few example data?

 

An example data would be a shopping cart with

 

item

amount

price

pants

12

20 

shirts

14

25

 

 

 

The actual string when echoed out is something like this; item id, item name, item price. (I left printing out the amount)

 

&item_name_1=Baseball Mitt&item_name_2=Soccer Ball&item_name_3=Hockey Stick
&amount_1=19.50&amount_2=25.00&amount_3=33.25

 

I hope that's what you were asking about.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.