单击“显示”按钮时显示特定数据

时间:2013-09-20 17:30:40

标签: php mysql

我对如何仅显示特定细节有疑问。比方说,我有两个表salessumarry和rsales,并为其表有这个ff数据。

来自rsales的

数据

id | name | last_name | age | salessumarry_id |
1  |gejel | rosenthal | 21  |        5        |
来自salessumarry的数据(注意:此数据来自数据库显示到我的网页)

id | or_no | sold_by | detail |
5  | 12456 |  fabbie | show   |
6  | 22222 |  nedy   | show   |

我的问题是这个。当我从我的网页点击“显示”时,它必须从rsales中选择数据,其中salessumarry_id = salessumarry.id。比方说,例如我点击show for id 5,预期输出必须是这样的

id | or_no | sold_by | detail |
5  | 12456 |  fabbie | show   |
id | name | last_name | age | salessumarry_id |
1  |gejel | rosenthal | 21  |        5        |
6  | 22222 |  nedy   | show   |

我把它放在我的“显示”按钮中,但我的想法仅限于此。当我点击显示

时,我不知道如何显示细节
echo '<td style="border-color:#000000; border-style:solid; border-width:1px;"><div align="center"><a  href=displaydetail.php?id=' . $row['id'] .'>show</a></div></td>';

1 个答案:

答案 0 :(得分:0)

这是完成您要做的事情的基本方法:

displaydetail.php
<?php
    // get salessumarry_id  from the URL
    $salessumarry_id = $_GET['id'];
    $query = "SELECT * FROM rsales WHERE salessumarry_id = '$salessumarry_id'";

    // use mysqli/pdo here to to execute the query 
    // and fetch the results into $results array and display it here:
    echo "id | name | last_name | age | salessumarry_id |<br>";
    echo $results['id']. " | ". $results['name']." | ".$results['last_name']." | ";
    echo $results['age']." | ".$results['salessumarry_id']." | ";
?>

希望这会有所帮助。这可以进一步改进,但首先你需要确保 这部分正在发挥作用。

相关问题