我在将所选行的数据显示到另一个div时遇到问题。
含义我显示例如forename和lastname,当用户点击名称(作为链接)时,我想显示所选Id中的更多数据,我希望它显示在div框中下面。
请在此处查看网站: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>
关心Maria
答案 0 :(得分:0)
在您的网站中,您的网址为空。你需要输入你的身份证。
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>