2011-03-31 52 views
0

我的查詢是:如何通過1回顯查詢結果1?

$qStuff=mysql_query("SELECT c.field_name,t.category_name, d.domain_name FROM category_fields c, taxonomy_category t, taxonomy_domain d WHERE c.category_id = t.category_id AND t.domain_id = d.domain_id AND c.field_name = '" . mysql_real_escape_string($first_word) . "'"); 

如何呼應c.field_name,t.category_name並分別d.domain_name?

輸出這樣

字段名稱:

類別名稱:

域名:

回答

2
while ($row = mysql_fetch_assoc($qStuff)) { 

    echo 'Field name: ' . $row['c.field_name'] . '<br />'; 
    echo 'Category name: ' . $row['t.category_name'] . '<br />'; 
    echo 'Domain name: ' . $row['d.domain_name'] . '<br />'; 

} 
0
<?php 
$qStuff=mysql_query("SELECT c.field_name,t.category_name, d.domain_name FROM category_fields c, taxonomy_category t, taxonomy_domain d WHERE c.category_id = t.category_id AND t.domain_id = d.domain_id AND c.field_name = '" . mysql_real_escape_string($first_word) . "'"); 


$result_array = mysql_fetch_assoc($qStuff); 
echo "Field name: ", $result_array["field_name"], "<br />"; 
echo "Category name: ", $result_array["category_name"], "<br />"; 
echo "Domain name: ", $result_array["domain_name"], "<br />"; 
echo "<br />"; 
?> 
0
<?php 

$qStuff = mysql_query("SELECT c.field_name,t.category_name, d.domain_name FROM category_fields c, taxonomy_category t, taxonomy_domain d WHERE c.category_id = t.category_id AND t.domain_id = d.domain_id AND c.field_name = '" . mysql_real_escape_string($first_word) . "'"); 

while($row = mysql_fetch_array($qStuff)){ 

    echo "Field Name: " . $row['c.field_name'] . "<br />"; 
    echo "Category Name: ". $row['t.category_name'] . "<br />"; 
    echo "Domain Name: " . $row['d.domain_name'] . "<br />"; 
} 
?>