Php 将数据从数据库显示到另一个div(从选定的$rowId)

Php 将数据从数据库显示到另一个div(从选定的$rowId),php,mysql,html,hyperlink,Php,Mysql,Html,Hyperlink,我在将选定行中的数据显示到另一个div时遇到问题 这意味着我正在显示例如forename和lastname,当用户单击名称(作为链接)时,我希望显示来自所选Id的更多数据,并且我希望它显示在下面的div框中 请参见此处的网站: 我的代码是: <div class="greenBox1"> <h1>1 - VÆLG DIN ONLINE COACH</h1> <div class="whiteBox1">

我在将选定行中的数据显示到另一个div时遇到问题

这意味着我正在显示例如forename和lastname,当用户单击名称(作为链接)时,我希望显示来自所选Id的更多数据,并且我希望它显示在下面的div框中

请参见此处的网站:

我的代码是:

<div class="greenBox1">
        <h1>1 - VÆLG DIN ONLINE COACH</h1>
            <div class="whiteBox1">
                <?php   
                    $sql = "SELECT * FROM coach ";

                    $coachId = $row["coachId"];
                    $fornavn = $row["fornavn"];
                    $efternavn = $row["efternavn"];

                    $result = mysql_query($sql);                
                    while($row=mysql_fetch_assoc($result))
                    {   

                        echo '<table border="0" align="left" height="100">';
                        echo '<tr>';
                        echo '<td width="95" rowspan="2" align="center" valign="middle"><img src="' . $row['imgUrl'] . '" width="85" height="85" alt="' . $row['imgAlt'] . '"/>' . '</td>'; 
                    ?>  
                        <!-- here I'm trying to write the id of the selected name to the div box below -->                              
                    <?  
                        echo '<td><a href="' . $coachId . '" target="whiteBox2"><h2>' . $row['fornavn'] . $row['efternavn'] . '</h2></a></td>';
                        echo '</tr>';

                        echo '<tr>';
                        echo '<td valign="top" width="190"><p>' . $row['beskrivKort'] . '<br></p></td>';
                        echo '</tr>';
                        echo '</table>';
                    }                           
                ?>                   
            </div>
        </div>

        <div class="greenBox2">
        <h1>2 - BOOK TID I COACHENS KALENDER</h1>
            <div class="whiteBox2" id="whiteBox2">
           <!-- here would like the more data to show -->
            </div>
        </div>

1-VÆLG DIN在线教练
2-第三次购买COACHENS KALENDER

在您的网站中,您的URL为空。你需要把你的身份证

echo '<td><a href="URLOFYOURSITE?id=' . $coachId . '" target="whiteBox2"><h2>' . $row['fornavn'] . $row['efternavn'] . '</h2></a></td>';
echo';
使用该URL,您将把ID作为GET变量发送。 如果设置了ID,则必须请求数据

<div class="whiteBox2" id="whiteBox2">
<?php
if (isset($_GET['id']))
{
    $sql = "SELECT * FROM coach WHERE coachId=" . (int)$_GET['id'];
    // Do your stuff...
    echo "Hello";
}
?>
<!-- here would like the more data to show -->
</div>


你在这段代码上面对的是什么样的pblm?但是仍然没有任何东西被写入,所以现在它工作了,谢谢你们,这太棒了,但我仍然不明白为什么它想打开正确框中的数据,但我需要一个新窗口??你能告诉我吗?