vorrei attraverso un form eliminare solo i record selezionati.
form html:
<?php
$db =& JFactory::getDBO();
$query = "
SELECT * FROM `#__chronoforms_tabella`";
$db->setQuery($query);
$results = $db->loadRowList();
$count=count($results);
?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF"> </td>
<td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF">#</td>
<td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td>
</tr>
<?php
foreach($results as $r){
?>
<tr>
<td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $r[0]; ?>"></td>
<td bgcolor="#FFFFFF"><?php echo $r[0]; ?></td>
<td bgcolor="#FFFFFF"><?php echo $r[1]; ?></td>
<td bgcolor="#FFFFFF"><?php echo $r[2]; ?></td>
<td bgcolor="#FFFFFF"><?php echo $r[3]; ?></td>
</tr>
<?php
}
?>
<tr>
<td colspan="5" align="center" bgcolor="#FFFFFF">
<input name="delete" type="submit" id="delete" value="delete"></td>
</tr>
</table>
</td>
</tr>
</table>
Enable Server Side Validation:
<?php
if (JRequest::getVar('delete','','post') == "delete") {
$i = $_POST['checkbox'];
foreach($i as $v)
{
$db =& JFactory::getDBO();
$query = "
DELETE FROM `#__chronoforms_tabella` WHERE codice='$v'";
$db->setQuery($query);
$db->Query();
return "eliminato";
}
}
?>
purtroppo non funziona, ne elimina solo uno.
e se non ci sono da errore.
grazie