XxDeadmanxX Posted October 7, 2007 Share Posted October 7, 2007 Ok so i made this script that if the position1 it makes it 2 and if its 6 it makes it box . But if its box it repeats to 1 for some reason. $result = mysql_query("SELECT * FROM pokemons where username='".$Valid_User."' order by position desc limit 1") or die(mysql_error()); $row = mysql_fetch_array( $result ); $positioncheck = $row['position']; if(!isset($positioncheck) OR $positioncheck=="" OR $positioncheck=="0"){ $positioncheck=1; }else{ $positioncheck = ($positioncheck+1); } if($positioncheck>6){ $positioncheck="box"; } Quote Link to comment https://forums.phpfreaks.com/topic/72140-help-me-please-with-this-please/ Share on other sites More sharing options...
JasonLewis Posted October 7, 2007 Share Posted October 7, 2007 what do you mean it 'repeats to 1'? does it reset the variable $positioncheck to 1? Quote Link to comment https://forums.phpfreaks.com/topic/72140-help-me-please-with-this-please/#findComment-363699 Share on other sites More sharing options...
ludjer Posted October 7, 2007 Share Posted October 7, 2007 look here 1 $positioncheck = ($positioncheck+1); 2 $positioncheck = ($positioncheck+1); 3 $positioncheck = ($positioncheck+1); 4 $positioncheck = ($positioncheck+1); 5 $positioncheck = ($positioncheck+1); 6 $positioncheck = ($positioncheck+1); $positioncheck="box"; <?php for($i =1;$i <7;$i++) { echo $i."<br>"; $positioncheck = $i; if(!isset($positioncheck) OR $positioncheck=="" OR $positioncheck=="0"){ $positioncheck=1; echo '$positioncheck=1;<br>'; }else{ $positioncheck = ($positioncheck+1); echo '$positioncheck = ($positioncheck+1);<br>'; } if($positioncheck>6){ $positioncheck="box"; echo '$positioncheck="box";<br>'; } } ?> it will always do $positioncheck = ($positioncheck+1); if this is false !isset($positioncheck) OR $positioncheck=="" OR $positioncheck=="0" if i understand you right try this replace else{ with elseif($positioncheck <6) { so it looks like this $result = mysql_query("SELECT * FROM pokemons where username='".$Valid_User."' order by position desc limit 1") or die(mysql_error()); $row = mysql_fetch_array( $result ); $positioncheck = $row['position']; if(!isset($positioncheck) OR $positioncheck=="" OR $positioncheck=="0"){ $positioncheck=1; elseif($positioncheck <6) $positioncheck = ($positioncheck+1); } if($positioncheck>=6){ $positioncheck="box"; } i think that is what you want Quote Link to comment https://forums.phpfreaks.com/topic/72140-help-me-please-with-this-please/#findComment-363710 Share on other sites More sharing options...
ludjer Posted October 7, 2007 Share Posted October 7, 2007 this is what i get when i run it if $positioncheck = 1 $positioncheck = ($positioncheck+1); if $positioncheck = 2 $positioncheck = ($positioncheck+1); if $positioncheck = 3 $positioncheck = ($positioncheck+1); if $positioncheck = 4 $positioncheck = ($positioncheck+1); if $positioncheck = 5 $positioncheck = ($positioncheck+1); if $positioncheck = 6 $positioncheck="box"; i moved my code around like this: $result = mysql_query("SELECT * FROM pokemons where username='".$Valid_User."' order by position desc limit 1") or die(mysql_error()); $row = mysql_fetch_array( $result ); $positioncheck = $row['position']; if($positioncheck>=6){ $positioncheck="box"; } if(!isset($positioncheck) OR $positioncheck=="" OR $positioncheck=="0"){ $positioncheck=1; elseif($positioncheck <6) $positioncheck = ($positioncheck+1); } case the $positioncheck = ($positioncheck+1); will make $positioncheck goto 6 when it is 5 Quote Link to comment https://forums.phpfreaks.com/topic/72140-help-me-please-with-this-please/#findComment-363722 Share on other sites More sharing options...
XxDeadmanxX Posted October 7, 2007 Author Share Posted October 7, 2007 No i mean when its "box" on database it makes new row number 1 instead i want after box i want it to keep on going box,box,box Quote Link to comment https://forums.phpfreaks.com/topic/72140-help-me-please-with-this-please/#findComment-363734 Share on other sites More sharing options...
MasterACE14 Posted October 7, 2007 Share Posted October 7, 2007 so you want the loop to continue, but with every result after 6 to be box? you can do this: when it reaches 6, start a new loop and close the old one. Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/72140-help-me-please-with-this-please/#findComment-363742 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.