找到你要的答案

Q:How could i execute another sql query on hyperlink click to display his whole details from DB

Q:我怎么能执行另一个SQL查询链接点击显示来自他的整个细节

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.

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

ABC将是超级链接。我想有一些想法或者骨架,onclick链接应该执行一个SQL查询,它应该给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']; 
}

点击“ABC”即链接…上面的查询应该被执行。纠正我,如果我错了或建议我一些想法,我将如何实现这一点。谢谢您.

answer1: 回答1:

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.

你目前的工作只是你需要获得候选人身份从URL查询然后运行查询PHP将候选人的细节,你将在该页面显示。

这将解决你的问题。

php  html  mysql