问题描述
我有一个数据库,可以容纳每个房屋的居民在某个街道上。我有一个'house view'的php网页,当使用'post'给出门牌号码时,它可以显示一个单独的房子和居民。我也有一个街景网页,其中列出了房屋清单。我想知道的是,如果街景上有链接,可以链接到房屋视图并同时张贴房屋号码,而无需为每个房屋设置一个表单?
I have a database which holds the residents of each house in a certain street. I have a 'house view' php web page which can display an individual house and residents when given the house number using 'post'. I also have a 'street view' web page which gives a list of houses. What I want to know is if you can have links on the street view which will link to the house view and post the house number at the same time without setting up a form for each?
Regards
推荐答案
我假设每个房屋都存储在自己的表格中,并有一个'id'字段,例如房屋编号。因此,当你循环访问房屋并显示它们时,你可以做这样的事情:
I assume that each house is stored in its own table and has an 'id' field, e.g house id. So when you loop through the houses and display them, you could do something like this:
<a href="house.php?id=<?php echo $house_id;?>">
<?php echo $house_name;?>
</a>
然后在house.php中,您将使用 $ _ GET获取房屋编号['id']
,使用 is_numeric()
验证它,然后显示它的信息。
Then in house.php, you would get the house id using $_GET['id']
, validate it using is_numeric()
and then display its info.
这篇关于如何使用链接发布数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!