将动态创建/填充的div链接到表

时间:2018-05-06 08:38:38

标签: php jquery html mysql

我正在开发一个网站页面,该页面将根据从数据库中提取的信息动态添加新div(基本上是联系人卡片)。因此,对于添加到数据库的每个新行,将在页面中添加新的div(联系人卡片)。我严格使用div,而不是表或列表。

对于每个div(联系人卡片),我创建了一个名为“与我联系”的按钮。单击“与我联系”按钮时,会出现一个模式表单,允许用户输入我希望发送给该联系人卡片所有者的信息,其中(tutor_tutid)是每个联系人的唯一标识符。用于填充div(联系人卡片)字段的信息从一个名为“tutors”的表中提取,每行都有“tutor_tutid”作为主键。

我的问题是,我不知道如何告诉HTML,例如,当点击DIV1(联系人卡片1)的“联系我”按钮时,用户应该在下一步填写的表格应该自动从“教师”表中分配到“tutor_tutid:1”。并且,DIV1(联系卡1)“联系我”按钮到“tutor_tutid:2”等等。

我知道如何编写代码以将填写的信息插入到所需的表中。我只是不知道如何将每个div / contact me按钮链接到显示其信息的用户。我想我可能需要jQuery这样做,但我不知道如何。

这就是我所拥有的:

<div class="teacher-info-container">
  <div id="tic1" class="teacher-info-column">
    <div class="teacher-pic-box">
      <div class="teacher-pic">
        <img src="images/defaulticon.png"></img>
      </div>

      <div class="teacher-name-box">
        Name: '. $row['tutor_tutfirst'] . '
        <br> Native: '. $row['tutor_tutlanguage'] .'
        <br> City: '. $row['tutor_tutcity'] .'
        <br>

      </div>
    </div>
  </div>
  <div id="tic2" class="teacher-info-column">
    <div class="tic-column2-header">
      Background, Education and Interests
    </div>
    <hr>
    <div class="teacher-background-box">

      <div class="tic-column2-fields">
        <div class="tic2-field-one">School
        </div>
        <div class="tic2-field-two">:
        </div>
        <div class="tic2-field-three">' . $row['tutor_tutschool'] . '
        </div>
      </div>

      <div class="clear"></div>

      <div class="tic-column2-fields">
        <div class="tic2-field-one">Major
        </div>
        <div class="tic2-field-two">:
        </div>
        <div class="tic2-field-three">'.$row['tutor_tutmajor'] .'
        </div>
      </div>

      <div class="clear"></div>

      <div class="tic-column2-fields">
        <div class="tic2-field-one">Experience
        </div>
        <div class="tic2-field-two">:
        </div>
        <div class="tic2-field-three">' . $row['tutor_tutexp'] .' years
        </div>
      </div>

      <div class="clear"></div>

      <div class="tic-column2-fields">
        <div class="tic2-field-one">Skill
        </div>
        <div class="tic2-field-two">:
        </div>
        <div class="tic2-field-three">'. $row['tutor_tutskill1'] . ', ' . $row['tutor_tutskill2'] . ', '. $row['tutor_tutskill3'] .'
        </div>
      </div>

      <div class="clear"></div>

      <div class="tic-column2-fields">
        <div class="tic2-field-one">Teaches
        </div>
        <div class="tic2-field-two">:
        </div>
        <div class="tic2-field-three">' . $row['tutor_tutlessonmode1'] . ', '. $row['tutor_tutlessonmode2']. '
        </div>
      </div>

      <div class="clear"></div>

      <div class="tic-column2-fields">
        <div class="tic2-field-one">Hobbies
        </div>
        <div class="tic2-field-two">:
        </div>
        <div class="tic2-field-three">' .$row['tutor_tuthobby1'] . ', ' . $row['tutor_tuthobby2'] . ', ' . $row['tutor_tuthobby3'] . '
        </div>
        <div class="hide-id">'.$row['tutor_tutid'].'</div>
      </div>
    </div>

  </div>

  <div id="tic3" class="teacher-info-column">
    <div class="introduction-box">
      <div class="introduction-header">Introduction</div>
      <div class="introduction-body">' . $row['tutor_tutintro']. '</div>
      <button id="fatmodalButton" class="tic3-button">CONTACT ME
                    </button>
    </div>
  </div>

</div>

0 个答案:

没有答案