Jump to content


Problem with mysql DB and Arrays...

  • Please log in to reply
1 reply to this topic

#1 eXtaZa

  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 15 April 2006 - 06:22 PM

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?


#2 Barand

  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 15 April 2006 - 06:53 PM

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.
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received


|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users