得到一个隐藏的表显示与点击php

  • 本文关键字:显示 php 隐藏 一个 php html
  • 更新时间 :
  • 英文 :


我创建了一个简单的学校成绩系统,只使用php,我试图找出如何得到一个隐藏的表,出现在主表下,当点击一个"durchschnitt号码">

下面是主表 的代码
<?php
if (!isset ($_SESSION['Saved_contacts']))           
$Kontakte = array (
array ("Hr.", "Fruehauf",   "Dennis", "13.02.2002", "Brucknerweg 34",  5212, "Hausen", '<a href="#" class="Fruehauf"><u>3.6</u></a>'),
array ("Fr.", "Kaufmann",   "Katharina", "04.03.2002", "Neubertbogen 24", 1680, "Romont", "Durchschnitt"),
array ("Hr.", "Fiedler",   "Marcel", "08.16.2002", "Via Stazione 98", 8143, "Stallikon", "Durchschinitt"),
array ("Hr.", "Oster",   "Tim", "08.26.2002", "Via delle Vigne 98", 1773, "Vuaty", "Durchschinitt"),
array ("Fr.", "Eichelberger",   "Tanja", "07.22.2002", "Semperweg 6", 4223, "Blauen", "Durchschinitt"));
else                                        
$Kontakte = $_SESSION['Saved_contacts'];
?>

<div style="width: 80%; min-width: 550px">
<h2>Kontakt des Schülers ...</h2>
<table>
<tr>  <th>Nr.</th> <th>Anrede</th> <th>Name</th> <th>Vorname</th> <th>Geburtsdatum</th> <th>Adresse</th> <th>PLZ</th> <th>Ort</th> <th>Durchschnitt</th> </tr>
<?php
for ($i=0; $i < count($Kontakte); $i++) {   
echo "<tr> <td><em>".($i+1)."</em></td>" . "<td style='text-align: center'>".$Kontakte[$i][0]."</td>" .
"<td>".$Kontakte[$i][1]."</td>" . "<td>".$Kontakte[$i][2]."</td>" . "<td>".$Kontakte[$i][3]."</td>" .
"<td>".$Kontakte[$i][4]."</td>" . "<td>".$Kontakte[$i][5]."</td>" . "<td>".$Kontakte[$i][6]."</td>" . " <td>".$Kontakte[$i][7]."</td
" . " <td><</tr>";
}
?>
</table>

正如你在最后一行的第一个数组中看到的,我做了一个链接,这样我就可以点击它。下面是我想要隐藏并重新出现的隐藏表

<div class="Note">
<div style="width: 80%; min-width: 550px">
<table class="grade_Fruehauf" style="">
<tr>
<th>Fruehauf</th>
</tr>
<tr>
<th>Deutsch</th>
<th>3.5</th>
</tr>
<tr>
<th>Math</th>
<th>3.5</th>
</tr>
<tr>
<th>Biologie</th>
<th>3.5</th>
</tr>
<tr>
<th>Französisch</th>
<th>4</th>
</tr>
<tr>
<th>Durchschnitt</th>
<th style="border-top:solid;">3.6<th>
</tr>
</table>
<div>
</div>

谢谢你的帮助

如果您只想使用PHP,那么您可以使用session,在单击link时在另一个文件中设置会话变量并重定向回来,检查该会话变量并显示/隐藏w.r.t它。(最好使用JavaScript)

最好使用javascript。您只需要在"durchschnitt编号"上添加onlick属性。td

<td onclick="show('tableid');"></td>

并为div或表指定一个id。:<table class="grade_Fruehauf" style="" id="example">

你需要一个像这样的javascript代码:

<script>
function show(tableid){
var x=document.getElementById(tableid);
if (window.getComputedStyle(x).visibility === "hidden") {
x.style.visibility = "visible";
}else{
x.style.visibility = "hidden";
}
}
</script>

最新更新