How to insert string split data into database using php
$client=split("\|", $input);
$n = trim($input);
// insert into Mysql
$output = "OK ... $client[0] $client[1] $client[2] $client[3]";
check above code and let get some ideas how to insert output into database with related fileds. I am using below code...
/ loop through array
$number = count($items);
for ($i=0; $i<=$number; $i++)
{
// store a single item number and quantity in local variables
$itno = $items[$i];
$quant = $quantities[$i];
if ($items[$i] <> '') {
mysql_query('INSERT INTO reservation_items (reservationID,productID,productQuantity) VALUES($theReservationID,$itno,$quant)');
}
}
This also I have tried..
$bill_no = $client[0];
$bill_amount = $client[1];
$item_name = $client[2];
$quantity = $client[3];
$rate = $client[4];
$amount = $client[5];
$discount = $client[6];
$query = mysql_query("INSERT INTO billing (bill_no, bill_amount, item_name, quantity, rate, amount, discount) VALUES ('$client[0]', '$client[1]', '$client[2]', '$client[3]', '$client[4]', '$client[5]', '$client[6]')");