我是 php 新手 .. 这是我的问题:我有 2 个展开的字符串,我想让第 2 个展开的字符串成为第一个展开的字符串的值,结果我想插入到我的数据库中,但是我插入没有任何问题。
例如,在下面的代码中,我希望 $date 成为 $layer 的值。$layer 的第一个词是 $date 的第一个词的值,第二个词是第二个词的值,依此类推..
$layer1=$_POST['layer'];
$date=$_POST['date'];
$layer=explode(",",$layer1);
$date=explode(",",$date);
foreach ($layer as $layer2=>$date )
{
//my problem is how to make the date a value to my layer?
$con=mysqli_connect("localhost","xxxx","xxx") or die ('unable to connect server');
mysqli_select_db($con, "xxxxxxxx") or die ('cant connect database');
$x="INSERT INTO xxxxx (Layer, date ) VALUES ('$layer2', '$date') ";
$result=mysqli_query($con,$x) or die ('cant proceed query');
//i want to appear look like this on database:
LAYER DATE
layer1 date1
layer2 date2
layer3 date3
say my data inputted from form is this one:
$_POST['layer']=layer1,layer2,layer3
$_POST['date']=date1,date2,date3