Page 1 of 1

Newbie: Possible to have a while inside a if/else

Posted: Fri Mar 20, 2009 4:54 am
by banan911dk
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


Hey

I've not written anything in PHP for a couple of years and now I have written something that is'nt working :twisted:

Is it not possible to have a while inside a if/else?

My code looks like this:

Code: Select all

<?php
 
mysql connection bla bla bla ;-)    
 
$counter = $nyplacering;
$nr = $counter + 1;
 
$counter2 = $nyplacering;
$nr2 = $counter2 - 1;
 
if ( $nyplacring < $nuplacering ) {
    mysql_query("UPDATE music SET nr='99' WHERE nr='$nyplacering'")  
 
    
    while ( $counter < $nuplacering ) {
 
    mysql_query("UPDATE music SET nr='$counter' WHERE nr='nr'")  
 
    $counter = $counter + 1;
    $nr = $nr + 1;
    
    }
    mysql_query("UPDATE music SET nr='$nuplacering' WHERE nr='99'")  
    
    echo "hurra";
    
    } else {
    
    
    if ( $nyplacring > $nuplacering ) {
    mysql_query("UPDATE music SET nr='99' WHERE nr='$nyplacering'")  
    
    while ( $counter2 > $nuplacering ) {
 
    mysql_query("UPDATE music SET nr='$nr2' WHERE nr='$counter2'")  
    $counter2 = $counter2 - 1;
    $nr2 = $nr2 - 1;
    
    }
    mysql_query("UPDATE music SET nr='$nyplacering' WHERE nr='99'")  
    
    echo "hurra2";
    
}
 
 
?>
 

pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.

Re: Newbie: Possible to have a while inside a if/else

Posted: Fri Mar 20, 2009 5:03 am
by mintedjo
I think you're missing some semi-colons from the ends of your lines