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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
banan911dk
Forum Newbie
Posts: 1
Joined: Fri Mar 20, 2009 4:50 am

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

Post 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.
mintedjo
Forum Contributor
Posts: 153
Joined: Wed Nov 19, 2008 6:23 am

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

Post by mintedjo »

I think you're missing some semi-colons from the ends of your lines
Post Reply