php html table tree
-
Ciao,
dopo varie ricerche per creare una tabella ad albero ho creato questo codice:<script> function Mostra(){ if ((document.getElementById(arguments[0]).checked) ) { document.getElementById(arguments[1]).style.display="block"; } else { document.getElementById(arguments[1]).style.display="none"; } } </script>per la parte javascript
e<table width="1215" border="1" cellspacing="0" cellpadding="0"> <tr> <th width="90" scope="col"> </th> <th width="90" scope="col">data</th> <th width="90" scope="col">schede</th> <th width="90" scope="col"> </th> <th width="77" scope="col">ora</th> <th width="139" scope="col">Call Status</th> <th width="201" scope="col">Subject</th> <th width="240" scope="col">Category</th> <th width="409" scope="col">product</th> </tr> <?php $contadata="select data,count(data) from Dati group by data order by data desc"; $cont=mysql_query($contadata)or die(mysql_error()); while($co=mysql_fetch_assoc($cont)){ $data=$co['data']; $contatore[$data]=$co['count(data)']; echo "<tr>"; echo "<td> <input type=\"checkbox\" name=\"sceltabanner\" id=\"".$data.$contatore[$data]."\" onclick=\"Mostra('".$data.$contatore[$data]."','".$data."');\" value=\"1\"/></td>"; echo "<td> ". $data."</td>"; echo "<td align=\"center\" >".$contatore[$data]."</td>"; echo "<td colspan=\"6\"> </td>"; echo "</tr>"; echo "<tr id=\"".$data."\" style=\"display:none\" >"; echo "<td colspan=\"3\"></td>"; echo "<td colspan=\"6\">"; $seleziona="Select ora,category,id,subject, product,call_status from Dati where data = '$data' order by id desc"; $query=mysql_query($seleziona)or die(mysql_error()); while($ra=mysql_fetch_assoc($query)){ $ora=$ra['ora']; $priority=$ra['subject']; $category=$ra['category']; $product=$ra['product']; $id=$ra['id']; $call_status=$ra['call_status']; echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\"><tr>"; echo "<td width=\"12\"><input name=\"idchiudi\" type=\"submit\" value=\"".$id."\"></td>"; echo "<td width=\"77\">".$ora."</td>"; echo "<td width=\"139\">".$call_status."</td>"; echo "<td width=\"201\">".$priority."</td>"; echo "<td width=\"240\">".$category."</td>"; echo "<td width=\"409\">".$product."</td>"; echo "</tr></table>" ; } echo " </td></tr>";} ?> </table>PRaticamente annido diverse tabelle(una per ogni record) come celle di una tabella principale
Il risultato è funzionale , ancche se carente dal punto vista visivo.Qualcuno puà aiutarmi a migliorarlo??
Grazie
Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.
Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.
Con il tuo contributo, questo post potrebbe essere ancora migliore 💗
Registrati Accedi