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
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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.