2013-05-22 60 views
2

我想根據其他三個字段中的信息從單個字段檢索數據。 作爲一個例子,如果我有一個表格,包含以下字段: 寬度,長度,高度,重量和顏色。 我想獲取字段顏色的值,其中width = $ value和length = $ value2和height = $ value。如何使用多個標準從數據庫中找到值?

+0

你的意思是,從數據庫數據retrive? – Jithu

+0

@Jithu他可能也在談論表格 – Max

+2

你幾乎*在你的問題中寫了SQL查詢! – John

回答

0

的SQL幾乎是你在你的問題寫了!

select color from yourtable 
    where width = $value and length = $value2 and height = $value 

PHP:

$result = $mysqli->query("SELECT color FROM yourtable WHERE width = $value AND length = $value2 AND height = $value"); 
+0

嘗試過,但無法通過執行以及$ result的回顯來顯示任何內容。我在這裏錯過了什麼嗎? – user2407883

+0

我想在這裏嘗試一些其他的。我在網上查了一遍後寫了它,但是如何適合你的代碼,我不知道,因爲你沒有顯示你的代碼。 – John

0
select color from table_name where width = $value and length = $value2 and height = $value3 

我假設你的意思是使用SQL ....

0

select 'singleFieldName' from table where width = $value AND length = $value2 AND height = $value3

0

試試這個

echo $query = "select color from yourtable_name 
     where width = '".$value1."' and length = '".$value2."' and height = '".$value3."'"; 
相關問題