我可以将两个选择元素中的值分配给一个变量吗?

时间:2014-03-29 12:11:35

标签: php sql variables

我对php很新,我对这段代码有各种各样的问题基本上我想将2个选项中的时间值添加到一个变量中,然后将该变量作为TIME存储在我的数据库中。我不清楚如何发布一个包含两个值的变量,它可能通过数组实现,但我已经尝试过,让我们说它毫无结果,请参阅下面的代码。

如果通过PHP,建议将更有用,请参阅表单的图像。

 <?php


 //connect to db
 include 'connect.php';

 //This is the directory where images will be saved 
 $event_type = $_POST['event_type']; 
 $title = strip_tags($_POST['title']); 
 $description = strip_tags($_POST['description']);
 $date = strip_tags ($_POST['date']); 
 $stime = $_POST['stime']);
 $etime = $_POST['etime'])
 $add1  = strip_tags($_POST['address1']);
 $add2  = strip_tags($_POST['address2']);
 $city = strip_tags($_POST['city']); 
 $postcode  = strip_tags($_POST['postcode']);
 $country = strip_tags($_POST['country']); 
 $tick  = strip_tags($_POST['tkqty']);
 $price = strip_tags($_POST['price']);
 $now = time();

 $image_name = addslashes($_FILES['image']['name']);
 $image_tmpname = addslashes($_FILES['image']['tmp_name']);
 $image_size = getimagesize($_FILES['image']['tmp_name']);



 if (strtotime($date) < $now) {
echo $errormsg = "that date is not valid";}



 if ($image_size==FALSE)
echo "That is not an image";
else 
{
if ($image_name)


$target = "uploaded/$image_name"; 
move_uploaded_file($_FILES['image']['tmp_name'],$target);
$user = $_SESSION['user_id'];

mysql_query ("INSERT into events VALUES('','$event_type','$title','$description','$date','$stime','$etime','$target','$add1','$add2','$city','$postcode','$country','$tick','$price','$user')");

  //Tells you if its all ok 
  echo "<h2> Event Add Successful</h2>";
  echo "Your event : ".$title." is now live, please return to <a href='manage_event.php'>manage           event</a> area. ";
  }


?>

enter image description here

1 个答案:

答案 0 :(得分:0)

我建议您在时间条目中创建两个新日期(小时和分钟,其余为零)。

将每个新日期添加到现有日期,捕获两个结果,然后您将拥有“datetime from”和“datetime to”,您可以将其存储在数据库中,如datetime字段。