2012-12-07 148 views
-1

我呼應的覆蓋,從數據庫中獲取超文本鏈接領域的清單採取的標題和副標題,動態表從數據庫

$area_shire = ''; 
$area_district = ''; 
$area_name = ''; 

while($rows = mysql_fetch_assoc($query)) { 

    if ($rows['area_shire'] != $area_shire) { 
     $area_shire = $rows['area_shire']; 
     $area_shire_url = str_replace(' ', '_', $area_shire); 
     echo '<h2><a href=Driveway_Cleaning_'.$area_shire_url.'>'.$area_shire.'</a></h2><br>'; 
    } 


    if ($rows['area_district'] != $area_district) { 
     $area_district = $rows['area_district']; 
     $area_district_url = str_replace(' ', '_', $area_district); 
     echo '<h3><a href=Driveway_Cleaning_'.$area_district_url.'>'.$area_district.'</a></h3><br>'; 

    } 


    if ($rows['area_name'] != $area_name) { 
     $area_name = $rows['area_name']; 
     $area_name_url = str_replace(' ', '_', $area_name); 
     echo '<a href=Driveway_Cleaning_'.$area_name_url.'>'.$area_name.'</a><br>'; 
    } 
    } 
?> 

這是給我的

線性輸出

西米德蘭

伯明翰

HARBORNE
埃德巴斯頓
莫斯利

達德利

哈索威
Sedgley

沃裏克

我試圖把輸出放到一個動態表,以便每個area_district(例如)達德利開始在新的一列,並因此在伯明翰的權利,而不是在下面。我所嘗試的一切都會影響輸出的順序。有任何想法嗎?

+0

什麼是對數據庫的查詢? – alditis

回答

1

爲什麼不嘗試使用HTML表格呢?或者將每個分組放在一個放置的分區中,以便它們可以放在一起的位置?我的主要建議是先解決你的HTML模板,然後研究如何將動態數據注入到它之後。