简体   繁体   English

使用PDO PHP和MySql

[英]Using PDO PHP and MySql

Alright peeps, This is my first question on stack overflow and it should be a easy one at that but since I cannot figure out what the right words for what I am trying to do its making it incredibly difficult for me to search it. 好的,偷看,这是我关于堆栈溢出的第一个问题,它应该很容易解决,但是由于我无法弄清要尝试执行的操作的正确词,这使我的搜索变得异常困难。

I am using PDO for my DB connection. 我正在使用PDO进行数据库连接。

Anyways, I am trying to query the database and then set $fname to a string, I know how to set it to an array like this while ($fname = $name->fetch()){} but how can I simply set $fname to a string instead? 无论如何,我试图查询数据库,然后将$fname设置$fname字符串,我知道如何while ($fname = $name->fetch()){}下将其设置为这样的数组,但如何设置$fname改为字符串?

The snippet of code and a link to where I can read more about it would be greatly appreciated. 代码片段和指向我可以阅读更多有关其的链接将不胜感激。

You mean like this? 你的意思是这样吗?

while ($fname = $name->fetch())
{
echo "{$fname['fieldName']}";
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM