Jump to content

Help Me Please With This. PLEASE!


XxDeadmanxX

Recommended Posts

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";
}

Link to comment
https://forums.phpfreaks.com/topic/72140-help-me-please-with-this-please/
Share on other sites

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

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.