<?php
//connection to the database
try {
$pdo = new PDO('mysql:host=localhost;dbname=frostedc_movies;charset=utf8',
frostedc_user, 'pass');
echo "connected";
}
catch(PDOException $e) {
echo $e; //2
}
// select everything from the news table
$query = "SELECT * FROM movie";// Table name NOT database name
foreach ($pdo->query($query) as $row) {
echo "<table border='1'>";
echo "<tr>";
echo "<td width='150'>".$row['movietitle']."</td>";
echo "<td width='150'>".$row['genre']."</td>";
echo "<td width='150'>".$row['LastViewed']."</td>";
echo "<td width='150'>".$row['Location']."</td>";
echo "</tr>";
}
echo "</tr>";
echo "</table>";
echo "<br>";
echo "
<form>
<p>Please Enter a Movie Title</p>
<input type='text' name='new_movie' />
<input type='submit' value='Submit' />
</form>";
echo "
<form>
<p>Please Enter the Genre</p>
<input type='text' name='movie_genre' />
<input type='submit' value='Submit' />
</form>";
echo "
<form>
<p>Please Enter the Last View Date</p>
<input type='text' name='last_view' />
<input type='submit' value='Submit' />
</form>";
echo "
<form>
<p>Please Enter the Location</p>
<input type='text' name='movie_loca' />
<input type='submit' value='Submit' />
</form>";
$pdo = null;
?>
这是新的更新代码。我正在尝试使用输入将数据输入到我的数据库中。我已经研究过如何做到这一点,但到目前为止我还没有任何工作。有什么想法吗?我是否更容易使用包含并在 html 中进行输入?如果是这样,我可以使用它们将数据输入数据库吗?