Jump to content
php.lv forumi

Dzēst ierakstus no db


djmartins

Recommended Posts

Man ir problēma ar ierakstu dzēšanu no datubāzes. Nestradā tāda iespēja ,ka var dzēst tos ierakstus kuri tiek atzīmēti ar checkbox.

 

<?php
$123=mysql_query("select * from msg where send='$lietotajs") or die(mysql_error());
while($r=mysql_fetch_array($123))
{
$delete=$r[0];
echo"$r[3]";
?>
<form name="checkbox" method="post" action ="del.php">
<input type="checkbox" name=<?php $delete ?> value=<?php $delete ?> ></td></tr>
<?php
}
?>
<input type="submit" name="delete" value="Dzēst">
</form>

 

del.php

<?php
include("con.php");
header ("location: index.php");
$checked = $_POST['$delete']; 

$count = count($checked); 
for($i=0; $i < $count; $i++) 
{ 
$query = "DELETE FROM msg WHERE id=$checked"; 
mysql_query($query); 
}

?>

 

kad checkbox nomaina pret type=text, un ieraksta ar roku vērtību, tad viss strādā. Problēma ir tajā, ka ar $_POST['$delete']; netiek iegūta msg id. Kas tiesi tur ir nepareizi, kādēļ ar checkbox vertību neiegūst bet ar input type=text vērtība tiek iegūta?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...