mes champs <tr> et <th> sont repété alors que mes echos sont dans <tr> et <td> ?
Salut,
mes titres sont répétés alors que mes "echo" sont dans les balises <tr><td> donc pas dans le titre. une solution ?
le bout de code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| <?php
$req = $bdd->query('SELECT * FROM annonce') or die(print_r($bdd->errorInfo()));
// $req->execute(array('id'=>10));
while($data = $req->fetch()){
?>
<div id="demo">
<table cellspacing="1" class="tablesorter">
<thead>
<tr>
<th>Ref.</th>
<th>Date de creation</th>
<th>Type de transaction</th>
<th>CP</th>
<th>Ville</th>
<th>Prix</th>
<th>Nb pieces</th>
<th>Surface</th>
<th>Visuel</th>
</tr>
</thead>
<tbody>
<?php
echo "<tr>";
echo "<td>".$data['reference']."</td>";
echo "<td>".$data['libelle']."</td>";
echo "<td>".$data['prix']."</td>";
echo "<td>".$data['honoraire']."</td>";
echo "<td>".$data['nombrepcs']."</td>";
echo "<td>".$data['nombrechambre']."</td>";
echo "<td>".$data['soustype']."</td>";
echo "<td>".$data['exclusivite']."</td>";
echo "<td>".$data['descriptif']."</td>";
echo "<td>".$data['recent']."</td>";
echo "<td>".$data['refait']."</td>";
echo "</tr>";
}?>
</tbody>
</table>
</div>
<?php
$req->closeCursor();
?> |
j'ai déjà réussi cette requête mais je ne trouve plus le script, merci pour votre aide
page entiere pour ceux qui se poserait la question :)
Voilà la soluce choisi:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
<?php
try{
$bdd = new PDO('mysql:host=localhost;dbname=annonce','root','');
}
catch (Exeption $e){
die('Erreur : '.$e->getMessage());
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>test nico</title>
<link rel="stylesheet" href="blue/style.css" type="text/css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.tablesorter.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("table").tablesorter({
sortList: [[0,0]]
});
}); </script>
</head>
<body>
<div id="demo">
<table cellspacing="1" class="tablesorter">
<thead>
<tr>
<th>Ref.</th>
<th>Date de creation</th>
<th>Type de transaction</th>
<th>CP</th>
<th>Ville</th>
<th>Prix</th>
<th>Nb pieces</th>
<th>Surface</th>
<th>Visuel</th>
</tr>
</thead>
<tbody>
<?php
$req = $bdd->query('SELECT * FROM annonce') or die(print_r($bdd->errorInfo()));
// $req->execute(array('id'=>10));
while($data = $req->fetch()){
echo "<tr>";
echo "<td>".$data['reference']."</td>";
echo "<td>".$data['libelle']."</td>";
echo "<td>".$data['prix']."</td>";
echo "<td>".$data['honoraire']."</td>";
echo "<td>".$data['nombrepcs']."</td>";
echo "<td>".$data['nombrechambre']."</td>";
echo "<td>".$data['soustype']."</td>";
echo "<td>".$data['exclusivite']."</td>";
echo "<td>".$data['descriptif']."</td>";
echo "<td>".$data['recent']."</td>";
echo "<td>".$data['refait']."</td>";
echo "</tr>";
}?>
</tbody>
</table>
</div>
<?php
$req->closeCursor();
?>
</body>
</html> |