eXtaZa Posted April 15, 2006 Share Posted April 15, 2006 Hello,so... I have this code(and I have a connection to the DB before, its just a example... ):[code]<html> <body> <form action="<?php Print $PHP_SELF ?>" method="POST"> <input type="submit" name="asd" value="Delete!"><BR> <?php $Result = mysql_query("SELECT * FROM GuestBook ORDER BY Date DESC"); while($a_row = mysql_fetch_row($Result)){ echo "<input type='checkbox' name='DeleteMe[]' value='$a_row'><BR>"; echo "</form>"; } if($_POST['asd']){ $a=$_POST['DeleteMe']; if(is_array($a)){ echo "yes"; foreach($a as $value) echo $value; } else echo "no"; } ?> </body> </html> [/code]I dont here that it will print me each time CheckBox, and to the CheckBox will be the value of the row that he get out of the DataBase.Then I dont that it check if what I'm sending is a array, If it is, he need to print me "yes", and then he need to print me every var that in the array.now, the problem is that just if im mark the first Checkbox, prints me:"yesArray"But why? Its true that it's array, but why he doesnt print every var in the array?And if I'm marking other CheckBox, except of the first CheckBox, it's print s me "no". But why? Its doesn't a array? Why just if I'm marking the firs CheckBox It's prints that its a array, And why he doesn't prints me all the vars that exist in the array? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/7495-problem-with-mysql-db-and-arrays/ Share on other sites More sharing options...
Barand Posted April 15, 2006 Share Posted April 15, 2006 1 ) you output "</form>" after every chekbox so only the first one is in the form.2 ) if you only echo a checkbox with no other details, how do you which record you are selecting for deletion?3 ) the value you assign to the checkbox should just be the id of the record to be deleted, not an array of the fields in the record. Quote Link to comment https://forums.phpfreaks.com/topic/7495-problem-with-mysql-db-and-arrays/#findComment-27305 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.