2013-02-10 73 views
-3

我怎样才能得到结果?:如何获得此MYSQL查询的结果?

$check = mysql_query("select username, email, case 
      when max(username = '$username') > 0 and max(email = '$email') > 0 then 'both' 
      when max(username = '$username') > 0 then 'username' 
      when max(email = '$email') > 0 then 'email' 
      end 
      from school_users 
      WHERE username = '$username' or email = '$email'") or die(mysql_error()); 

我需要的“用户名”或“电子邮件”或“both”时,它的存在。我如何接收这些变量?

+1

你检查http://php.net/mysql_query? – zerkms 2013-02-10 21:15:45

+1

您不应该使用'mysql_query'函数,因为它已被弃用。改为使用'mysqli_query'。 – Luka 2013-02-10 21:17:46

+2

这可能是他的另一个问题的延续:http://stackoverflow.com/questions/14800674/how-would-i-stop-multiple-emails-or-username。我想你在这里提问之前需要学习一点研究。 – 2013-02-10 21:28:06

回答

0

好吧,我想我明白你正在尝试做的。你有更多的工作比你想象的要多。你需要的是模板,以便你可以自己创建。下面的链接将允许您创建自己的php API,以您所说的方式与MySQL数据库进行通信。这是一步一步的,他给你的代码工作,所有的!

android login and registration with php mysql and sqlite

我用它和它的IT真棒,如果您有任何问题随时给我发短信。

把绿色检查,如果这有帮助