从mysql数据库中检索数据并使用php将其插入表中

时间:2022-06-01 17:54:17

I design 3 pages in html with bootstrap framework, one is i can insert data to database the second it shows subject and date of the data i inserted in database in a html table and i want the 3rd page to get data from database when i click on recorded data in table and show it in the 3rd page.

我在html中使用bootstrap框架设计了3个页面,一个是我可以将数据插入到数据库中,第二个显示主题和数据的日期我插入数据库中的html表格中我希望第三页从数据库中获取数据在表格中记录的数据,并在第3页显示。

|-------|----------|--------------|
| No    |   Subject   | Date      |
|-------|----------|--------------|
|  1    |      A   |   2016       |
|-------|----------|--------------|
|  2    |      B   |   2016       |
|-------|----------|--------------|

when i click on A i want to get data about A project from Database and when i click on B i want to get details about B project in another Page from databse.

当我点击A我想从数据库获取有关项目的数据时,当我点击B时,我想从数据库获取另一个页面中B项目的详细信息。

i don't have any idea how to do that with php and html.

我不知道如何用PHP和HTML做到这一点。

sorry for bad English

抱歉英语不好

1 个解决方案

#1


1  

Pass Project No with GET Variable and retrieve that data with that ID in 3rd page like this :

使用GET变量传递Project No并在第3页中检索具有该ID的数据,如下所示:

Second Page :

第二页:

<tr>
    <td><?=$project->no;?></td>
    <td><?=$project->subject;?></td>
    <td><a href="localhost/3rdpage.php?id=<?=$project->no;?>">Details</a></td>
</tr>

Third Page :

第三页:

$projectNo = $_GET['id'];

$stmt = $pdo->prepare('SELECT * FROM project WHERE no = ?');
$stmt->execute(array($projectNo));
$data = $stmt->fetch(PDO::FETCH_OBJ);

#1


1  

Pass Project No with GET Variable and retrieve that data with that ID in 3rd page like this :

使用GET变量传递Project No并在第3页中检索具有该ID的数据,如下所示:

Second Page :

第二页:

<tr>
    <td><?=$project->no;?></td>
    <td><?=$project->subject;?></td>
    <td><a href="localhost/3rdpage.php?id=<?=$project->no;?>">Details</a></td>
</tr>

Third Page :

第三页:

$projectNo = $_GET['id'];

$stmt = $pdo->prepare('SELECT * FROM project WHERE no = ?');
$stmt->execute(array($projectNo));
$data = $stmt->fetch(PDO::FETCH_OBJ);