doucigua0278 2015-03-17 23:50
浏览 97

使用列表框中选择的选项创建表

The below code displays a form with a drop-down list that populates the fields of the form when an option is selected from the list. I want to select an option from the drop-down list and use that selection to create a table when the Schedule button is pressed. The problem I am having is the table that is getting created actually contains every training course that matches the sql query, and not just the one training course that I selected. I only want to display the one training course and say that it was scheduled, not the entire database full of training courses that match the query.

<?php
include 'reportBox.php';
?><br><br>
<form name = "reportForm" action = "scheduleCourse.html.php" onsubmit="return confirmcheck()" method="POST">
            <input type="hidden" id="courseID" name="courseID" disabled>
            <label for="tcTitle">Title:</label>
            <input type="text" name="tcTitle" id="tcTitle" disabled /><br/><br>
            <label for="tcProvider">Provider:</label> 
            <input type="text" id="tcProvider" name="tcProvider" disabled><br><br>
            <label for="tcVenue">Venue:</label> 
            <input type="text" id="tcVenue" name="tcVenue" disabled><br><br>
            <label for="tcFee">Fee:</label> 
            <input type="text" id="tcFee" name="tcFee" disabled><br><br>

<input type = "submit" value = "Schedule">
</form>

A snippet of the code that creates the table on a new page when Schedule is pressed

$sql = "SELECT * FROM Training_Course WHERE tcDeleted = false  AND tcStartDate > CURDATE()";
    produceReport($sql);

function produceReport($sql){
    $result = mysql_query($sql);
    if($result === FALSE) { 
        die(mysql_error()); 
    }

    echo "<table><tr><th>Start Date</th><th>Number of Days</th><th>Start Time</th><th>End Time</th></tr>";
    while ($row=mysql_fetch_array($result)){
        echo "<tr align='center'>
        <td>".$row['tcStartDate']."</td>
        <td>".$row['tcLength']."</td>
        <td>".$row['tcStartTime']."</td>
        <td>".$row['tcEndTime']."</td>";
    }
    echo "</table>";

Any ideas please?

Dropdown list:

http://imgur.com/uxgfEdB

The table that is created:

http://imgur.com/fJsuliY

As you can see, it displays information for 4 courses, instead of just the course I have selected in the drop-down list

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 测距传感器数据手册i2c
    • ¥15 RPA正常跑,cmd输入cookies跑不出来
    • ¥15 求帮我调试一下freefem代码
    • ¥15 matlab代码解决,怎么运行
    • ¥15 R语言Rstudio突然无法启动
    • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
    • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥100 为什么这个恒流源电路不能恒流?