如何使用mysql_fetch_array的结果?
我对此使用了 while 语句,我可以很好地回显每一行,
echo $row['myrow'];
但我想要的是将结果放入链接中,如下所示:
echo "<img src='http://www.mysite.com/images/$row['myrow'].jpg'>";
但它不起作用。我做错了什么?
I'm using a while statement on this and I can echo each row fine i.e
echo $row['myrow'];
but what I want is to have the result put into a link like so:
echo "<img src='http://www.mysite.com/images/$row['myrow'].jpg'>";
But it doesn't work. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
要么以这种方式回显:
或者,恕我直言,这样更好:
给出 有关双引号字符串的文档 快速刷新。
Either echo it this way:
Or, IMHO much better, this way:
Give the documentation on double quoted-strings a quick refresh.
另一种不错的方法是仅将 PHP 用于代码的动态部分。我认为这会导致代码看起来更漂亮。
当然,整个 img 标签不应该在 PHP 代码块中,因为它是常规 HTML。
Another nice way to do it is to only use PHP for the dynamic part of the code. I think it results in nicer looking code.
Then of course the whole img tag should not be in a PHP code block, since it regular HTML.
您需要注意您的报价...
试试这个:
另请注意,您没有关闭该元素。
You need to take care of your quotes...
Try this:
Also notice that you didn't close the element.
访问字符串内的数组元素和对象属性/方法必须用大括号括起来(字符串解析)
Accessing array elements and object properties/methods inside the string must be enclosed in curly braces (string parsing)
为了使它完整,哈哈
to make it complete, lol
您已在 example.com 位置写入您的网站网址
you have write your site url on place of example.com