我有一個問題..我今天嘗試了很多工作,但對我來說似乎是不可能的..所以我決定在這裏尋求幫助。所以當我按下提交按鈕時,我需要在數據庫表中添加一個表單。 這是PHP代碼我目前使用..我打消了我的嘗試BTW:Mysql將表格插入數據庫表PDO
<?php
$pdo = new PDO('mysql:host=;dbname=', '', '');
$sql = "SELECT * FROM games LIMIT 10";
foreach ($pdo->query($sql) as $row) {
?>
我的HTML代碼(形式):
<form class="form-group" method="POST" action="">
\t <div role="tabpanel" class="tab-pane active" id="home">
\t \t <div class="form-group" style="margin-top: 15px;">
\t \t \t <label for="exampleInputEmail1">Game Title</label>
\t \t \t <input type="text" class="form-control" id="exampleInputEmail1" placeholder="" name="gtitle" />
\t \t </div>
\t \t <div class="form-group">
\t \t \t <label for="exampleInputPassword1">YouTube Link</label>
\t \t \t <input type="text" class="form-control" id="exampleInputPassword1" placeholder="" name="ytlink" />
\t \t </div>
\t \t <div class="form-group">
\t \t \t <label for="exampleInputPassword1">Link Source</label>
\t \t \t <input type="text" class="form-control" id="exampleInputPassword1" placeholder="ex: GLEAM, DLH, FAILMID, HRKGAME, INDIEGALA, OTHER, STEAM" name="slink" />
\t \t </div>
\t \t <div class="form-group">
\t \t \t <label for="exampleInputPassword1">Link to Free Steam Keys</label>
\t \t \t <input type="text" class="form-control" id="exampleInputPassword1" placeholder="KEY MUST GIVE +1 TO THE STEAM LIBRARY GAME COUNT" name="keysl" />
\t \t </div>
\t \t <label for="exampleInputPassword1">Steam App ID</label>
\t \t <div class="input-group" style="padding-bottom: 10px;">
\t \t \t <span class="input-group-addon" id="basic-addon3">http://store.steampowered.com/app/</span>
\t \t \t <input type="text" class="form-control" id="basic-url" aria-describedby="basic-addon3" placeholder="App ID" name="appid" />
\t \t </div>
\t \t <div class="form-group">
\t \t \t <label for="exampleInputPassword1">Categories</label>
\t \t \t <div class="checkbox">
\t \t \t \t <label class="radio-inline">
\t \t \t \t \t <input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1" /> 1
\t \t \t \t \t <h4><span class="label label-success">Keys Available</span></h4>
\t \t \t \t </label>
\t \t \t \t <label class="radio-inline">
\t \t \t \t \t <input type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2" /> 2
\t \t \t \t \t <h4><span class="label label-danger">No Keys left</span></h4>
\t \t \t \t </label>
\t \t \t </div>
\t \t \t <button type="submit" class="btn btn-default" name="insert">Submit</button>
\t \t </div>
\t </div>
</form>
謝謝那些幫助我的人。
你得到了什麼錯誤? –
您將不得不使用INSERT語句插入數據庫。 http://dev.mysql.com/doc/refman/5.7/en/insert.html – Jonny