Let me tell you , mysqli_fetch_assoc() will be returning an associative array ( see http://php.net/manual/en/mysqli-result.fetch-assoc.php ) so either you need to use foreach( $row as $key => $value ) { //statement } or $row['<column name>']; without foreach . If you are using foreach( $row[ 'key'] as $value ) { //statement } there is no need of for loop . Better look the doc and just give a print_r() in the while . You will understand . Hari K T http://harikt.com/ ________________________________ From: hno <hno2005@xxxxxxxxx> To: php-objects@xxxxxxxxxxxxxxx Sent: Tue, 1 December, 2009 12:36:01 AM Subject: RE: Problem with while You did not understand me.the $row[‘key’] is true and key is the name of the column. Thanks image002 HNO From: php-objects@ yahoogroups. com [mailto:php-objects@ yahoogroups. com] On Behalf Of Hari KT Sent: November 30, 2009 11:40 AM To: php-objects@ yahoogroups. com Subject: Re: Problem with while Your foreach must be like foreach( $row as $key => $value ) { //statement } and not $row[ 'key'] . Hari K T http://harikt. com/ ____________ _________ _________ __ From: hno <hno2005@gmail. com <mailto:hno2005% 40gmail.com> > To: php-objects@ yahoogroups. com <mailto:php- objects%40yahoog roups.com> Sent: Mon, 30 November, 2009 12:04:10 PM Subject: Problem with while HI How can have a while and a foreach in it? I have something like this: While($row=mysqli_ fetch_assoc( $r)){ // code Foreach($row[ 'key'] as $value){ //code } } But the while loop run just one time and I'm sure it should run more than one time and I know the problem is with the foreach .by the way,I can't delete the foreach from the while because It works with each row from the while loop. Does anybody has any idea about it? thanks image002 HNO [Non-text portions of this message have been removed] The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. http://in.yahoo. com/ [Non-text portions of this message have been removed] [Non-text portions of this message have been removed] The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. http://in.yahoo.com/ [Non-text portions of this message have been removed]