我对PHP很陌生,在MySQL中也不太熟练。
我正在尝试从数据库中获取信息并使用唯一ID将信息放入不同的div中 - 我的意思是,例如:
分配给ID 1的div将显示该ID的条目,div = ID 2将执行相同的操作,依此类推。
这是我到目前为止所拥有的:
包含Article类的Article.php文件用于DB处理。
这是我从网站上将信息插入表格的方式。 ID是自动递增的(我想在我的情况下这并不是一件好事);
public function insertInfobar()
{
// Insert the infomartion into Infobar
$conn = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD );
$sql = "INSERT INTO infobar ( title, subtitle, additional ) VALUES ( :title, :subtitle, :additional )";
$st = $conn->prepare ( $sql );
$st->bindValue( ":title", $this->title, PDO::PARAM_STR );
$st->bindValue( ":subtitle", $this->subtitle, PDO::PARAM_STR );
$st->bindValue( ":additional", $this->additional, PDO::PARAM_STR );
$st->execute();
$conn = null;