Jump to content


This topic is now archived and is closed to further replies.


Problem with mysql DB and Arrays...

Recommended Posts

so... I have this code(and I have a connection to the DB before, its just a example... ):

<form action="<?php Print $PHP_SELF ?>" method="POST">
<input type="submit" name="asd" value="Delete!"><BR>
$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>";

echo "yes";
foreach($a as $value)
echo $value;
echo "no";

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:
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?


Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.