djmartins Posted June 6, 2010 Report Share Posted June 6, 2010 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? Quote Link to comment Share on other sites More sharing options...
sandis_m Posted June 6, 2010 Report Share Posted June 6, 2010 galīgi greizs kods izskatās vai man arī vajag brilles Quote Link to comment Share on other sites More sharing options...
101111 Posted June 6, 2010 Report Share Posted June 6, 2010 Palasi par check box specifiku, kad dati tiek sūtīti uz serveri Quote Link to comment Share on other sites More sharing options...
djmartins Posted June 6, 2010 Author Report Share Posted June 6, 2010 (edited) nu liels paldies Jums par palīdzību. Kļūda bija pie checkbox value=<?php echo"$delete"; ?> Viens vārds echo un lieta darīta. Iespējams ka šādi nav labākais variants, bet strādā. Edited June 6, 2010 by djmartins Quote Link to comment Share on other sites More sharing options...
emsy Posted June 7, 2010 Report Share Posted June 7, 2010 Labāks variants: <?=$delete;?> Quote Link to comment Share on other sites More sharing options...
mefisto Posted June 7, 2010 Report Share Posted June 7, 2010 Nē , nav labāks. Quote Link to comment Share on other sites More sharing options...
KarlisBa Posted June 7, 2010 Report Share Posted June 7, 2010 (edited) Nē , nav labāks. Kāda tad alternatīva ir labāka? Edited June 7, 2010 by KarlisBa Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.