如何在插入表n之前连接两个列值同时存储同一个表

时间:2016-11-09 11:24:29

标签: php mysql insert concatenation

我希望连接两个Textbox值并以不同的名称存储同一个表,同时插入查询

例如

$Standard= $_POST['Standard'];
$division = $_POST['division'];
$RollNo = $_POST['RollNo'];
$Year = $_POST['Year'];
$Class_ID = $Standard.$division.$Year;
$Student_ID = $Class_ID.$RollNo;

<form action="#" method="POST">

            <label>Standard</label> 
            <input type="text" name="Standard"> 

            <label>division</label> 
            <input type="text" name="division"> 

            <label>Roll No</label> 
            <input type="text" name="RollNo"> 
            <label>Year</label> 
            <?php
            $already_selected_value = 1984;
            $earliest_year = 1990;
            print '<select name="Year">';
            foreach (range(date('Y'), $earliest_year) as $x) {
            print '<option value="'.$x.'"'.($x === $already_selected_value ? ' selected="selected"' : '').'>'.$x.'</option>';
                }
                print '</select>';
            ?>
        </div> 
            <button type="submit" class="btn btn-default w3ls-button" name="button">Submit</button> 
    </form> 

此处我有Textbox标准,分区,RollNoYear,我创建了一个用于从文本框中获取数据的变量。但是在这里我还在class_Id中创建了两个额外的变量$Class_ID$Student_ID,并且我希望连接$Standard+$division+$Year$Student_ID = $Class_ID+$RollNO然后我想在表中插入所有值:

$sql = "INSERT INTO `class`(Student_ID, Class_ID, Standard, division, RollNo, Year) VALUES ('$Student_ID','$Class_ID','$Standard','$division','$RollNo','$Year')";

0 个答案:

没有答案