karthicbabu.83 0 Newbie Poster

here is my table data..

here is my table data..

(4 Columns/1row in mysql table)

id                 bno                            date                      results
310                001                02-15-2020               MI,108.53
                                       Oh,194.57
                                       PA,182.22
                                       WA,238.57

How to split(statemiles) single column into (state, Miles) two columns and output like following 5 columns /4rows in mysql using php code.

(5 Columns in mysql table)
------------------------------------------------------------------------------------

id                  bno                             date                  result1     result2

310                001                02-15-2020               MI          108.53

310                001                02-15-2020           Oh          194.57

310                001                02-15-2020           PA          182.22

310                001                02-15-2020           WA          238.57

Following php code split two columns perfectly..
(screenshot below)

separated_columns.jpg

<?php
//invoice.php  
include('../includes/config.php');

if(isset($_POST["add"]))
{
$order_no=$_POST['order_no'];
$comma = preg_replace('/,\\s*/', "', '", $_POST["stateandmileslist"]);
$row = preg_replace('/\\n/', "'), \n('", $comma);
$query = "insert into tis_satesmiles (states, miles) values ('" . $row . "')";
$statement = $dbh->prepare($query);
$statement->execute();
}
?>

But how can i update or insert order_no and order_date input values in same table?

Following attachment shown form page how users submit values

click_mileagebutton.jpg

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.