如何将动态数据库值从一个html元素连接到另一个? [英] How to connect dynamic db value from one html element to another?

查看:74
本文介绍了如何将动态数据库值从一个html元素连接到另一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难制定这个问题所以这是可以理解的,但是这里有。



我有一个名为apartments.php的页面。在这个页面上,我列出了我公司数据库中的一些行,你可以表示有兴趣租用。

公寓的打印方式如下:



 <?php  
foreach ( $ apartments as $ apartment){?>
< tr >
< td > <? php echo $ apartment [' apartments_room'] ?> < / td >
< td > <? php echo $ apartment [ apartments_area'] ?> < / td >
< td > <? php echo $ apartment [' apartments_rent'] ?> < / td >
< td > <? php echo $ apartment [' apartments_address' ] ?> < / td >
< td > <? php echo $ apartment [' apartments_floor'] ?> < / td >
< td > <? php echo $ apartment [' apartments_city'] ?> < / td >
< td > < span class =code-pagedirective><? php echo $ apartment [' apartments_freeFromDate'] ?> < / td >
< td > < a href = data-reveal-id = < ?php echo $ apartment ['apartments_id']?> 名称 = id = 按钮 > 申请!< / a > < / td > ;
< / tr >
<? php} ?>





打印出来的每间公寓都有自己的按钮。按此按钮时,将显示模态/弹出窗口。

这是我的问题。



当模态弹出时,我希望它显示公寓的信息,我按下了按钮。

因此,按钮中的data-reveal-id值(代表特定公寓的db-id)是我需要进入模态div的id-value。另外我需要写出那个公寓的地址(db列'apartments_address')。



这就是我需要它的方式:



 <   div     id   = 这里我需要获取ID    class   =  reveal-modal >  
< h2 > AND HERE我需要打印地址的名称< / h2 >

//这里我为申请人腾出空间离子形式,但这是无关紧要的......
< / div >





这应该不是件事,对吧?我希望你能帮助我。谢谢!



(如果重要的话,我会使用基础Zurb 4的模态。)

解决方案

apartments as


apartment){?>
< tr >
< td > <? php echo


apartment [ ' apartments_room'] ?> < span class =code-keyword>< / td >
< td > <? php 回波

I had a hard time to formulate this question so it would be understandable, but here goes.

I have a page called apartments.php. On this page I list a number of rows from my database on apartments that you can show interest to rent.
The apartments are printed out like this:

<?php				
foreach ($apartments as $apartment) { ?>
     <tr>
        <td><?php echo $apartment['apartments_room'] ?></td>
	<td><?php echo $apartment['apartments_area'] ?></td>
	<td><?php echo $apartment['apartments_rent'] ?></td>
	<td><?php echo $apartment['apartments_address'] ?></td>
	<td><?php echo $apartment['apartments_floor'] ?></td>
	<td><?php echo $apartment['apartments_city'] ?></td>
	<td><?php echo $apartment['apartments_freeFromDate'] ?></td>
	<td><a href="#" data-reveal-id="<?php echo $apartment['apartments_id'] ?>" name="id" class="button">Apply!</a></td>
      </tr>
<?php } ?>



Each apartment that gets printed out has its own button. When you press this button, a modal / popup will show.
And here's my problem.

When the modal pops up I want it to show the information of the apartment from witch I pressed the button.
So the data-reveal-id value from the button (that represent the specific apartment's db-id) is what I need to get into the modal divs id-value. Additionally I need to write out the address of that apartment (the db column 'apartments_address').

So this is how I need it to be:

<div id="HERE I NEED TO GET THAT ID" class="reveal-modal">
   <h2>AND HERE I NEED TO PRINT OUT THE NAME OF THE ADDRESS</h2>

   // Here i make room for an application form, but that's irrelevant...
</div>



This shouldn't be a hard thing, right? I hope you can help me out. Thanks!

(For more details if it matters, I'm using the modal of Foundation Zurb 4.)

解决方案

apartments as


apartment) { ?> <tr> <td><?php echo


apartment['apartments_room'] ?></td> <td><?php echo


这篇关于如何将动态数据库值从一个html元素连接到另一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆