我知道这可能很简单,但我是 PHP 和 MySQL 开发的新手,所以我很感激一些帮助。我在 Stack 上找不到我可以理解的现有示例,因此我将其发布在那里,希望得到一些指导。
我有一个包含地址信息的数据库表。我将地址分成两个字段,house_number 和 street_name,我需要做的是显示按街道名称分组的信息,然后按门牌号排序。
我已经模拟了一个我需要页面外观的示例。它在第一列中具有偶数地址,在第二列中具有奇数地址。我正在使用 Twitter Bootstrap 进行格式化。
$address = mysql_query("SELECT id, house_number, street_name, full_address FROM resident WHERE neighborhood_id = $neighborhood_id order by street_name, house_number;");
它应该是什么样子
下面的 HTML 代码:
<!--STREET GROUPING -->
<div class="row-fluid">
<div class="span12">
<h3>ASHTON PARK WAY</h3>
</div>
</div >
<div class="row-fluid">
<div class="span6"><!-- EVEN ADDRESSES -->
<a href="#" class="btn btn-large btn-white btn-block">18102 Ashton Park Way</a>
<a href="#" class="btn btn-large btn-white btn-block">18104 Ashton Park Way</a>
<a href="#" class="btn btn-large btn-white btn-block">18106 Ashton Park Way</a>
<a href="#" class="btn btn-large btn-white btn-block">18108 Ashton Park Way</a>
<a href="#" class="btn btn-large btn-white btn-block">18110 Ashton Park Way</a>
<a href="#" class="btn btn-large btn-white btn-block">18112 Ashton Park Way</a>
<a href="#" class="btn btn-large btn-white btn-block">18114 Ashton Park Way</a>
<a href="#" class="btn btn-large btn-white btn-block">18116 Ashton Park Way</a>
</div><!-- END EVEN ADDRESSES -->
<div class="span6"><!-- ODD ADDRESSES -->
<a href="#" class="btn btn-large btn-white btn-block">18101 Ashton Park Way</a>
<a href="#" class="btn btn-large btn-white btn-block">18103 Ashton Park Way</a>
<a href="#" class="btn btn-large btn-white btn-block">18105 Ashton Park Way</a>
<a href="#" class="btn btn-large btn-white btn-block">18107 Ashton Park Way</a>
<a href="#" class="btn btn-large btn-white btn-block">18109 Ashton Park Way</a>
<a href="#" class="btn btn-large btn-white btn-block">18111 Ashton Park Way</a>
<a href="#" class="btn btn-large btn-white btn-block">18113 Ashton Park Way</a>
</div><!-- END ODD ADDRESSES -->
</div>
<!-- END STREET GROUPING -->
<hr>
<!--STREET GROUPING -->
<div class="row-fluid">
<div class="span12">
<h3>HAMDEN PARK WAY</h3>
</div>
</div >
<div class="row-fluid">
<!-- EVEN ADDRESSES -->
<div class="span6">
<a href="#" class="btn btn-large btn-white btn-block">18102 Hamden Park Way</a>
<a href="#" class="btn btn-large btn-white btn-block">18104 Hamden Park Way</a>
<a href="#" class="btn btn-large btn-white btn-block">18106 Hamden Park Way</a>
<a href="#" class="btn btn-large btn-white btn-block">18108 Hamden Park Way</a>
<a href="#" class="btn btn-large btn-white btn-block">18110 Hamden Park Way</a>
<a href="#" class="btn btn-large btn-white btn-block">18112 Hamden Park Way</a>
</div>
<!-- END EVEN ADDRESSES -->
<!-- ODD ADDRESSES -->
<div class="span6">
<a href="#" class="btn btn-large btn-white btn-block">18101 Hamden Park Way</a>
<a href="#" class="btn btn-large btn-white btn-block">18103 Hamden Park Way</a>
<a href="#" class="btn btn-large btn-white btn-block">18105 Hamden Park Way</a>
<a href="#" class="btn btn-large btn-white btn-block">18107 Hamden Park Way</a>
</div>
<!-- END ODD ADDRESSES -->
</div>
<!-- END STREET GROUPING -->