How to insert capital letters to Mysql?

How to insert data into a mysql table from an array using php?

  • am new to php and need help regarding array insertion into mysql table i have an array when i add and item to the shopping cart $_session['cart_array'] = array("item_id" => $pid, "quantity"=>1) now if i have one item in cart when i do print_r($_session['cart_array']) array looks like Array( [0] => Array ( [item_id] => 1 [quantity] => 1 ) ) now i need to insert this array data to a table named purchased_products having columns id, product_name, product_quantity please help me out its urgent thanks php mysql

  • Answer:

    if it were me, I would loop through the array and build the query, then execute it once. Like this $output = 'insert into table(item_id,pid,quantity) values'; foreach($array_name as $row){ $output .= " ('{$row['item_id']}', '{$orw['pid']}', {$row['quantity']}),"; } //then you need to correct for the extra comma $output = substr($output,0,strlen($output)-1); //then query mysql_query($output); Now I haven't checked this, but it should be close to what you need. Good luck.

Ahmad at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

if it were me, I would loop through the array and build the query, then execute it once. Like this $output = 'insert into table(item_id,pid,quantity) values'; foreach($array_name as $row){ $output .= " ('{$row['item_id']}', '{$orw['pid']}', {$row['quantity']}),"; } //then you need to correct for the extra comma $output = substr($output,0,strlen($output)-1); //then query mysql_query($output); Now I haven't checked this, but it should be close to what you need. Good luck.

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.