1

我正在尝试将 plan_id 插入数据库,其中 plan_name =(从选择中选择)

你能帮我弄清楚这个片段有什么问题吗

<?php
$plan_id = ($a);
$query = "INSERT INTO tbl_reservation(cust_id, pack_type, plan_id, res_date, res_venue,     date_app) VALUES     ('{$cust_id}','{$pack_type}','{$plan_id}','{$res_date}','{$res_venue}',CURDATE())";
$result_set = mysql_query($query);
?>
<select name="plan_id">
<?php 
    $queryy = mysql_query("SELECT * FROM tbl_wed_plan");
    while ($row = mysql_fetch_array($queryy)){
    $plan_id = $row['plan_id'];

    echo"<option value='.$row[plan_name].'>$row[plan_name]</option>";
    }

    $a = '';
    if('plan_id' == 'Sho Minamimoto') {
    $a = 'plan-01';
    }else if('plan_id' == 'Janine Tugonon') {
    $a = 'plan-02';
    }else if('plan_id' == 'Jessie Jameson') {
    $a = 'plan-03';
    }else if('plan_id' == 'Karl Marx Bautista') {
    $a = 'plan-04';
    }
?>
4

2 回答 2

0

这是更正的代码:用户$plan_id而不是'plan_id'

<?php
$plan_id = ($a);
$query = "INSERT INTO tbl_reservation(cust_id, pack_type, plan_id, res_date, res_venue,     date_app) VALUES     ('{$cust_id}','{$pack_type}','{$plan_id}','{$res_date}','{$res_venue}',CURDATE())";
$result_set = mysql_query($query);

<?php 
    $queryy = mysql_query("SELECT * FROM tbl_wed_plan");
    while ($row = mysql_fetch_array($queryy)){
    $plan_id = $row['plan_id'];

    echo"<option value='".$plan_id."'>".$row['plan_name']."</option>";
    }

    $a = '';
    if($plan_id == 'Sho Minamimoto') {
    $a = 'plan-01';
    }else if($plan_id == 'Janine Tugonon') {
    $a = 'plan-02';
    }else if($plan_id == 'Jessie Jameson') {
    $a = 'plan-03';
    }else if($plan_id == 'Karl Marx Bautista') {
    $a = 'plan-04';
    }
?>
于 2013-09-13T07:39:43.413 回答
0

连接问题..我猜

echo"<option value='".$plan_id."'>".$row[plan_name]."</option>";
于 2013-09-13T07:42:45.437 回答