PHP SQL从何处选择 [英] PHP SQL Select From Where
本文介绍了PHP SQL从何处选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在运行一些SQL代码时遇到了一些困难.
I am having some difficulty running some SQL code.
我想做的是,找到包含正确用户名的行,然后从该正确行中获取一个值.
What I am trying to do is, find a row that contains the correct username, and then get a value from that correct row.
这是我在php中的SQL:
This is my SQL in the php:
mysql_query("SELECT * FROM users WHERE joined='$username' GET name")
如您所见,它会在用户中查找用户名,然后找到用户名,则必须从正确的行中获取一个值.
As you can see, it looks for a username in users and then once found, it must GET a value from the correct row.
我该怎么做?
推荐答案
您需要一些其他PHP代码(对mysql_fetch_array的调用)来处理MySQL返回的结果资源.
You need some additional PHP code (a call to mysql_fetch_array) to process the result resource returned by MySQL.
$result = mysql_query("SELECT name FROM users WHERE joined='$username'");
$row = mysql_fetch_array($result);
echo $row['name'];
这篇关于PHP SQL从何处选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文