PHP MYSQL 显示来自 dB 的图片链接
嘿,我有一个名为 Box1 的表,其结构简单:id(increment,primary) imageurl、link。
我想要做的是在我的网站上的 HTML 文件中,将 imageurl 显示到 imgsrc 中,以便图像 URL 在访问该网站时加载图像,
我无法在网上找到具体要查找的内容,并且知道我必须靠近某个地方,这就是我到目前为止在 .php 文件编码中所得到的内容......谢谢。
<?php
$con = mysql_connect("localhost","data","data");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}else {
mysql_select_db("database1", $con);
$result = mysql_query("SELECT * FROM Box1 ORDER BY id DESC LIMIT 1");
while($row = mysql_fetch_array($result))
{
echo $row['image'];
// NEXT STEP IS TO DISPLAY THE the IMAGE EXAMPLE: '<img src code<?php echo 'image'; ?>' >
}
}
mysql_close($con)
?>
如果你能指导我如何做到这一点,那就太棒了,我很困惑如何用 PHP 实现 HTML,谢谢!
Hey all I have a table caleld Box1, with a simple structure of: id(increment,primary) imageurl, link.
What I am looking to do, is on my site in the HTML file, display the imageurl into a imgsrc, so that the Image URL loads the image when going to the site
I cannot find specifically what I am looking for online and know I must be close somewhere, this is what I have so far in my coding for my .php file.... thanks.
<?php
$con = mysql_connect("localhost","data","data");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}else {
mysql_select_db("database1", $con);
$result = mysql_query("SELECT * FROM Box1 ORDER BY id DESC LIMIT 1");
while($row = mysql_fetch_array($result))
{
echo $row['image'];
// NEXT STEP IS TO DISPLAY THE the IMAGE EXAMPLE: '<img src code<?php echo 'image'; ?>' >
}
}
mysql_close($con)
?>
if you could guide me to an exmaple of how to do this, that would be amazing, im so confused how one would implement HTML with PHP, thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此外,对于大块 html 来说,熟悉该运算符也很有帮助
Also, it is helpful to become familiar with this operator for large chunks of html