php – 将echo插入具有id或类的div的特定html元素中

前端之家收集整理的这篇文章主要介绍了php – 将echo插入具有id或类的div的特定html元素中前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有这个代码.
<html>
<head>
<style type="text/css">
body{background:#666666;}
div{border:1px solid red;}
</style>
</head>
<body>
<?PHP

$con = MysqL_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . MysqL_error());
}

MysqL_select_db("juliver",$con);

$result = MysqL_query("SELECT * FROM hi");

while($row = MysqL_fetch_array($result))
{

echo '<img src="'.$row['name'].'" />';  
echo "<div>".$row['name']."</div>";
echo "<div>".$row['title']."</div>";
echo "<div>".$row['description']."</div>";
echo "<div>".$row['link']."</div>";
echo "<br />";
}

MysqL_close($con);

?>
</body>
</html>

上面的代码工作.

现在,我想插入这个

echo '<img src="'.$row['name'].'" />'; 
echo "<div>".$row['name']."</div>";
echo "<div>".$row['title']."</div>";
echo "<div>".$row['description']."</div>";
echo "<div>".$row['link']."</div>";
echo "<br />";

在html中指定的div或其他元素,例如,我将插入这个

echo '<img src="'.$row['name'].'" />';

进入html元素.

我不知道该怎么做,请帮助我.谢谢

Juliver

参考基本信息.
$sql = "INSERT INTO MyGuests (firstname,lastname,email)
VALUES ('John','Doe','john@example.com')";
if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

猜你在找的PHP相关文章