我如何在超链接上执行另一个 sql 查询以显示他从数据库中的全部详细信息 [英] How could i execute another sql query on hyperlink click to display his whole details from DB

查看:42
本文介绍了我如何在超链接上执行另一个 sql 查询以显示他从数据库中的全部详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将如何使用查询字符串从数据库中获取 deyails.我使用 PHP 在 HTML 表中获取并显示了详细信息.表格在 HTML 表格中看起来像这样 -

ID |姓名 |指定……………………1 |ABC |开发商2 |PQR |测试员3 |XYZ |开发商

其中 - ABC 将是一个超链接.我想知道一些想法或框架,它应该在超链接的 onClick 中执行另一个 SQL 查询,并且应该提供所需的 ABC 详细信息.

<table class="table table-hover"><tr><th>ID</th><th>姓名</th><th>指定</th></tr><tr><?php如果(mysql_num_rows($result)>0){while($row=mysql_fetch_array($result)){$var1=$row['cand_number'];$var2=$row['cand_fname'];?><tr><td><a href="viewcandidate.php?var=<?php echo urlencode($var1);?>"><?php echo urlencode($var1);?></><td><td><?php echo $row['cand_fname'];?></td><td><?php echo $row['cand_desc'];?></td></tr><?php}}?></tr>

$sql = "SELECT * FROMCandidate ".$join.'其中'.$条件;while($row=mysql_fetch_array($result)){$FirstName =$row['cand_fname'];$LastName=$row['cand_lname'];$Position =$row['cand_postion'];$Gender=$row['cand_gender'];}

点击ABC"即链接...上面的查询应该被执行.如果我错了,请纠正我们或向我提出一些想法,我将如何实现这一目标.谢谢.

解决方案

对于您当前的工作,您只需要从 url 查询中获取候选人 ID,然后在 php 中运行查询,这将返回您将在该页面中显示的候选人详细信息.

这将解决您的问题.

How would i fetch deyails from database using query string.I have a fetched and displayed the details, in HTML table using PHP. The table look such in HTML table -

ID | NAME | Designatioon
........................
1 | ABC | Developer
2 | PQR | Tester
3 | XYZ | Developer

where - ABC would be a hyperlink. I would like to have some idea or skeleton where onClick of hyperlink it should execute another SQL query and it should give the desired details of ABC.

<div class="box-body table-responsive no-padding">
   <table class="table table-hover">
   <tr>
      <th>ID</th>
      <th>Name</th>
      <th>Designation</th>

  </tr>
  <tr>
     <?php
    If(mysql_num_rows($result)>0)
    {

    while($row=mysql_fetch_array($result))
    {  
    $var1=$row['cand_number'];
    $var2=$row['cand_fname'];
    ?>
    <tr>
    <td><a href="viewcandidate.php?var=<?php echo urlencode($var1);?>"><?php echo urlencode($var1);?></a><td>
    <td><?php echo $row['cand_fname']; ?></td> 
    <td><?php echo $row['cand_desc']; ?></td> 
    </tr>
    <?php

    }
    }
    ?>
   </tr>
</table>

$sql = "SELECT * FROM candidate ".$join.' where '.$condition;


while($row=mysql_fetch_array($result))
{ 
$FirstName  =$row['cand_fname']; 
$LastName=$row['cand_lname']; 
$Position =$row['cand_postion']; 
$Gender=$row['cand_gender']; 
}

On click "ABC" i.e the link...the above query should get executed. Correct us if I am wrong or suggest me some ideas ,how would i achieve this. Thank You.

解决方案

For your current work just you need to get candidate id from url query and then run query in php which will return candidate details which you will show in that page.

This will solve your problem.

这篇关于我如何在超链接上执行另一个 sql 查询以显示他从数据库中的全部详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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