weixin_33725722 2020-03-23 15:24 采纳率: 0%
浏览 25


I'm trying to use a while loop inside in PHP And Ajax.

But I only get the First ID, not the 2nd, 3rd and so on.

Here is the code Of PHP:

<div class="container pt-5 my-5">
<section class="p-md-3 mx-md-5 text-center">
    <h2 class="text-center mx-auto font-weight-bold mb-4 pb-2">Our Team</h2>
    <div class="row">
        <?php while ($t_run=mysqli_fetch_array($t_query)){?>
            <div class="col-lg-3 col-md-4 col-sm-6 mb-4">
                <div class="p-4">
                    <div class="avatar w-100 white d-flex justify-content-center align-items-center">
                        <input type="hidden" name="team" class='team_id' value="<?php echo $t_run['id']?>">
                        <img src='images/<?php echo $t_run['img']?>'class="team_img rounded-circle z-depth-1-half"/>
                    <div class="text-center mt-2">
                        <h6 class="font-weight-bold pt-2"><?php echo $t_run['name']?></h6>
                        <p class="text-muted">
                            <small><i><?php echo $t_run['title']?></i></small>
                        <button class="team btn-info border-0 p-2 rounded">View profile</button>
        <?php }?>

and here is the Ajax code I use

<script type="text/javascript">
    $(document).ready(function () {
       $('.team').click(function (){
           var name = $('.team_id').val();
  • 写回答



      相关推荐 更多相似问题


      • ¥30 如何降低hdfs中datanode的JVM内存用量
      • ¥15 Android URL如何转成视频/音频,可行吗?
      • ¥20 SQL数据查询,子查询
      • ¥15 c++字符串分割问题
      • ¥15 vue+uniapp
      • ¥15 android freedom
      • ¥15 关于STM32的SPI和ENDAT接口编码器通信的问题
      • ¥15 关于#pdfbox#生成的PDF文件正常,转图片中文乱码的问题,如何解决?
      • ¥15 ADS中有关DAC控件的使用问题
      • ¥15 win11如何运行geoserver