在php中列出页面重定向问题

k97glaaz  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(373)

我在php上工作,我已经从数据库获取了所有数据,我必须显示列表页面,我必须显示列表页面中的所有动态日期&我正在从数据库获取所有数据,但如何重定向和显示列表页面,我是如何尝试这个我没有得到请检查我的代码和帮助我。
下面是我的html代码:

<div class="col-lg-3 col-md-6  test" data-idtest="Diabetes">
                    <a href="javascript:void(0);" class="box_cat_home">
                        <i class="icon-info-4"></i>
                        <img src="assets/img/icon_cat_3.svg" width="60" height="60" alt="">
                        <h3>Diabetes</h3>
                        <ul class="clearfix">
                        <li><strong>124</strong>Doctors</li>
                        <!-- <li><strong>60</strong>Clinics</li> -->
                        </ul>
                    </a>
                </div>

我的jquery代码:

<script type="text/javascript">
 $(document).ready(function() { 
        $('.test').click(function (){
            var id = $(this).data('idtest') ; 
            alert(id);
        $.ajax({
        type: "POST",
         url : "speciallist.php",
        data    : {id:id },
        cache: false,
        success: function(data){
           console.log(data);
        }
      });
      })
    });
</script>

下面是我的php代码:

<?php
$dbHost = 'localhost';
$dbUsername = 'root';
$dbPassword = 'mysql';
$dbName = 'fre';
$db = new mysqli($dbHost,$dbUsername,$dbPassword,$dbName);

$id =$_REQUEST['id'];

      $men ="select * from tbl_users where doctor_speciality='$id'";
      $men_result=$db->query($men);
      $projects=array();
      while($row=mysqli_fetch_assoc($men_result)){ 
      $projects[] = $row;
  }
?>

动态列表页面:specialist.php

<div class="col-lg-12 list-items">
                    <?php foreach($projects as $row){
                    $userId = $row['userId'];?>
                <div class="strip_list wow fadeIn">
                    <a href="#0" class="wish_bt"></a>
                    <figure>
                        <!-- <a href="detail.php"><img src="http://via.placeholder.com/565x565.jpg" alt=""></a> -->
                        <a href="detail.php?userId=<?php echo $userId;?>"><img src="<?php echo "admin/uploads"."/".$row['doctor_image']; ?>"</a>
                    </figure>
                    <a href="detail.php?userId=<?php echo $userId;?>"><h3><?php echo $row['name']; ?></h3></a>
                    <p><!-- Doctor Education : --> <?php echo $row['doctor_education']; ?>,<?php echo $row['doctor_speciality']; ?></p>
                    <p> 9 years experience</p>
                    <p>Gynecologist/Obstetrician</p>
                    <!-- <p> Doctor Speciality : <?php echo $row['doctor_speciality']; ?></p> -->
                    <!-- <p><?php echo $row['doctor_profile']; ?></p> -->
                    <p><!--  Mobile : --> <?php echo $row['mobile']; ?></p>
                    <!-- <p><?php echo $row['doctor_profile']; ?></p> -->
                    <!-- <p>Dr. Mr is a Senior Endodontist, specializes in Smile Designing, Single Visit Root Canal Treatments, Implants, Cosmetic Dentistry.</p> -->
                    <div class="sideleft">
                        <p>Clinic Name:<?php echo $row['clinic_name']; ?></p>
                        <p>Clinic Address:<?php echo $row['clinic_address']; ?></p>
                    </div>
                    <ul>
                        <li>MON-SAT 9:00 AM - 9:30 PM</li>
                        <li><a href="detail.php?userId=<?php echo $userId;?>">Book now</a></li>
                    </ul>
                </div>
                <?php }?>
                </div>
z3yyvxxp

z3yyvxxp1#

将“php代码”添加到specialist.php的顶部,并将javascript代码更改为:

<script type="text/javascript">
  $(document).ready(function() { 
    $('.test').click(function (){
        var id = $(this).data('idtest') ; 
        alert(id);
        document.location = "speciallist.php?id=" + id;
    });
  });
</script>

相关问题