dpthuyh1678 2018-03-10 23:29
浏览 32
已采纳

通过锚标记从db获取相关数据

My code:

<?php
if (isset($_GET["q"]))
{
    $q= $_GET["q"];   # this is team name 

    $link=mysqli_connect("localhost","root","");
    mysqli_select_db($link,"onesports");
    $result=mysqli_query($link," select * from team where team_name='" .$q. " ' ");
    $result2=mysqli_query($link,"select  players.full_name, team.* from players,team where team.team_name='" .$q. " ' and players.team_name=team.team_name ");
    while($row = mysqli_fetch_array($result)) {
  ?>
    <table>
        <tr>        
        <td style="font-size: 30px; font-variant-caps:petite-caps;" > <?php echo $row['team_name'];  ?> </td>
        <td style="text-transform: capitalize; "> <?php  echo "(";    echo  $row['city'] ; echo ",";  echo $row['prov']; echo ")";  ?> </td>            
 </tr>
   <tr>
        <td style="text-transform: capitalize;">      
            <?php echo $row['captain']; echo "(c)";  ?>        
        </td>         
        <td style="text-transform: capitalize;"> <?php echo $row['coach'];  ?> </td>
   </tr>    

    </table>
   <hr>
       <?php
    }
    echo '<table cellpadding="0" cellspacing="0" class="db-table">';
    echo "<tr>";
    echo "<th>";
    echo "Players";
    echo "</th>";
    echo "</tr>";
    while($row = mysqli_fetch_array($result2)) {    
        echo "<tr>"; 
        echo "<td>";
        echo '<a href= " "  >' . $row['full_name'] . '</a>';
        echo "</td>";
        echo "</tr>";
    }
    echo "</table>";

The problem is that I'm getting full_name dynamically, every name has some details in db I want to get. When I click on full_name, I want it to give me all the related data from the DB. This is the part with the links:

echo '<table cellpadding="0" cellspacing="0" class="db-table">';
echo "<tr>";
echo "<th>";
echo "Players";
echo "</th>";
echo "</tr>";
while($row = mysqli_fetch_array($result2)) {    
    echo "<tr>"; 
    echo "<td>";
    echo '<a href= " "  >' . $row['full_name'] . '</a>';
    echo "</td>";
    echo "</tr>";
}
echo "</table>";

So kindly help me. Do you suggest that I use any other tag rather than an anchor tag, or you can tell me how to get data this way?

  • 写回答

4条回答 默认 最新

  • drmqzb5063 2018-03-10 23:59
    关注

    As I got the point, you need to retrieve the information by clicking the relevant link. You can use the following structure:

    echo '<a href="?FN='.$row["full_name"].'">'.$row["full_name"].'</a>';
    

    Then at your server-side code, get the data by using

    $_GET['FN']

    I hope this answer help you as well as.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 如何将下列的“无限压缩存储器”设计出来
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口