2013-02-10 63 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真棒,如果您有任何問題隨時給我發短信。

把綠色檢查,如果這有幫助