使用php创建动态html表单

时间:2017-04-28 15:20:24

标签: php html mysql

我有一个html表单,我希望预先填充来自sql表的数据,具体取决于按下哪个链接进入表。例如(表单用于更新其中包含不同事件的表格)如果我点击链接编辑足球比赛的详细信息,表单将预先加载足球比赛的详细信息,以便更容易用户。

显示编辑表链接的php脚本 - 包括'database_conn.php'; //这链接到创建数据库连接的php脚本

include 'database_conn.php';      // This links to the php script which makes db connection

$sql = "SELECT eventID, eventTitle FROM AE_events ORDER BY eventID";

$result = $dbConn->query($sql);

if ($result->num_rows > 0) {

while($row = $result->fetch_assoc()) {
    echo "<p>". $row["eventID"]. " <a href='editTable.php'>" . $row["eventTitle"] . "</a></p>";
}
} else {
echo "0 results";
}

$dbConn->close();
?>

我想要预先加载数据的表

<form>
<form id="eventEdit" action="View_Events3.php" method="get">
    Event title <input type="text" name="eventTitle" accesskey="f"/><br/>
    Event venue <select accesskey="g">
    <option value="theatre royal">Theatre royal</option>
    <option value="baltic centre for contemporary art">BALTIC Centre For Contemporary Art</option>
    <option value="laing art gallery">Laing Art Gallery</option>
    <option value="the biscuit factory">The Biscuit Factory</option>
    <option value="discovery mueseum">Discovery Mueseum</option>
    <option value="HMS calliope">HMS Calliope</option>
    <option value="metro radio arena">Metro Radio Arena</option>
    <option value="mill volvo tyne theatre">Mill Volvo TYNE Theatre</option>
    <option value="playhouse whitley bay">Playhouse Whitley Bay</option>
    <option value="shipley art gallery">Shipley Art Gallery</option>
    <option value="steven stories">Steven Stories</option>
</select>
    <br/>
    Event Category <select accesskey="h">
    <option value="carnival">Carnival</option>
    <option value="theatre">Theatre</option>
    <option value="comedy">Comedy</option>
    <option value="exhibition">Exhibition</option>
    <option value="festival">Festival</option>
    <option value="family">Family</option>
    <option value="music">Music</option>
    <option value="sport">Sport</option>
    <option value="dance">Dance</option>
</select> <br/>
    Event start date <input type="date" name="eventStartDate" accesskey="i"/><br />
    Event end date <input type="date" name="eventEndDate" accesskey="j"/><br />
    Event price <input type="number" name="eventPrice" accesskey="k"/><br />
    Event description <textarea style="width:500px; height:120px;" accesskey="l"></textarea ><br />

0 个答案:

没有答案