0

選択した行のデータを別の div に表示する際に問題があります。

たとえば、ユーザーが名前をクリックすると (リンクとして)、名前と姓を表示していることを意味し、選択した Id からより多くのデータを表示したいと思います。

こちらのサイトをご覧ください: http://kristoff.it/onlinecoaching/

そして私のコード:

<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>

よろしくマリア

4

1 に答える 1

0

あなたの Web サイトでは、URL が空です。IDを入れる必要があります。

echo '<td><a href="URLOFYOURSITE?id=' . $coachId . '" target="whiteBox2"><h2>' . $row['fornavn'] . $row['efternavn'] . '</h2></a></td>';

その 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>
于 2013-05-07T10:41:06.243 に答える