Mettre du php dans javascript
Salut :D , j'ai trouver dans le net se code pour supprimer une ligne d'un tableau Html
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
| <SCRIPT language="javascript">
function addRow(tableID) {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var cell1 = row.insertCell(0);
var element1 = document.createElement("input");
element1.type = "checkbox";
cell1.appendChild(element1);
var cell2 = row.insertCell(1);
cell2.innerHTML = rowCount + 1;
var cell3 = row.insertCell(2);
var element2 = document.createElement("input");
element2.type = "text";
cell3.appendChild(element2);
}
function deleteRow(tableID) {
try {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
for(var i=0; i<rowCount; i++) {
var row = table.rows[i];
var chkbox = row.cells[0].childNodes[0];
if(null != chkbox && true == chkbox.checked) {
table.deleteRow(i);
rowCount--;
i--;
}
}
}catch(e) {
alert(e);
}
}
</SCRIPT> |
et voici mon code php qui lire a partir de la base de donnée et afficher dans un tableau html
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
| <table id="rounded-corner" >
<thead>
<tr>
<th scope="col" class="rounded-company"></th>
<th scope="col" class="rounded">Titre</th>
<th scope="col" class="rounded">Description</th>
<th scope="col" class="rounded">Nom du fichier</th>
<th scope="col" class="rounded">Date d'ajout</th>
<th scope="col" class="rounded">Modifier</th>
<th scope="col" class="rounded-q4">Supprimer</th>
</tr>
</thead>
<tbody>
<tr>
<td><div id="Ch"><input type="checkbox" name="" /></div></td>
<?php
include("connexion.php");
$req1=$bdd->query('select * from reglement');
while($reponse1 = $req1->fetch()){
?>
<td><?php echo $reponse1['titrereg'] ?></td>
<td><?php echo $reponse1['desciroptionreg'] ?></td>
<td><?php echo $reponse1['lienreg'] ?></td>
<td><?php echo $reponse1['datereg'] ?></td>
<td><a href="#"><img src="images/user_edit.png" alt="" title="" border="0" /></a></td>
<td><a href="#" class="ask"><img src="images/trash.png" onclick="deleteRow('rounded-corner')" alt="" title="" border="0" /></a></td>
</tr>
<?php
}
?>
</tbody>
</table> |
Maintenant je veux savoir comment faire pour integrer la requete de suppression dans le code, pour qu'il efface la ligne de la base donnée pas seulement du tableau.