Jump to content

Recommended Posts

hi i use java scrip with php to make minimize for menu It work good but my prob in if statment

 

it's a mafagame so i need to hide som things for law ranks i think u all understand that

<center>
<script language="javascript">
function showMenu(id) {
  if(document.getElementById(id).style.visibility == "hidden") {
    document.getElementById(id).style.position      = "static";
    document.getElementById(id).style.visibility    = "visible";
  }
  else {
    document.getElementById(id).style.visibility    = "hidden";
    document.getElementById(id).style.position      = "absolute";
    document.getElementById(id).style.left      = -100;
    document.getElementById(id).style.top       = -100;
  }

  document.getElementById('mainTable').height       = '100%';
}
</script>
<?
ob_start();
include("db.php");

?>
<link rel=stylesheet href=in.css>

<?
$username = $_COOKIE['username'];
$sql = MySql_Query("SELECT * FROM users WHERE username = '".$username."'");
$user = MySql_Fetch_Array($sql);
?>
<center>
<table border=1 bordercolor=#000000 cellpadding=0 cellspacing=0 width=90%>
<th class=kop><a href=# onclick="showMenu('Earning')">Earning</a></th>
<tr id=Earning>
    <td id=Earning>

        - <a href=index.php?p=uCrime target=game alt="Do Crimes In The Omen World">Crimes</a><br>
        - <a href=index.php?p=trade target=game alt="Make Trade & Deceive PPL
">Trading</a><br>
        - <a href=index.php?p=bank target=game alt="This is the Gangsta World newspaper.">Bank</a><br>
    </td>
</tr>

<th class=kop><a href=# onclick="showMenu('traveling')">Traveling</a></th>

<tr id=traveling>
    <td id=traveling>
    - <a href=index.php?p=travel class=menu target=game>Travel</a><br>
    - <a href=index.php?p=vehicle class=menu target=game>Vehicles</a><br>
    
    </td>
</tr>

<th class=kop><a href=# onclick="showMenu('Gambling')">Gambling</a></th>
<tr id=Gambling>
    <td id=gambling>
           - <a href=index.php?p=rps class=menu target=game>Rock, Paper, Scissors</a><br>
           - <a href=index.php?p=rr class=menu target=game>Russian Roulette</a><br>
           - <a href=index.php?p=slot class=menu target=game>Slot</a><br>
           - <a href=index.php?p=Dice class=menu target=game>Dice</a><br>
           - <a href=index.php?p=gan class=menu target=game>Guess Numbers</a><br>
           - <a href=index.php?p=lottery class=menu target=game>Lottery</a><br>
    </td>
</tr>
<th class=kop><a href=# onclick="showMenu('Forum')">Forum</a></th>
<tr id=forum>
<td id=forum>
<?
if($this_user['crew'] != 0) {
  ?>
    
- <a href=index.php?p=crewforum&fid=$user['crew'] class=menu target=_parent>Crew Forum</a><br>
  <?  
  }
     elseif($user['rank'] >= 99) {
   	?>
    - <a href=index.php?p=forum&fid=-1 class=menu target=game>Admin</a><br>
  
    <?
    }
    ?>
    <?
        $q = mysql_query("SELECT * FROM forum WHERE crew = 0");
     $for = mysql_fetch_object($q) 
       
    ?>
    - <a href=index.php?p=forum&fid=$for['id']>$for['name']</a></br>
    </td>
</tr>
<?
  if(!(safety($user['id'] == -1 && $user['safety'] == 1)){
  	?>
<th class=kop><a href=# onclick="showMenu('war')">War</a></th>
<tr id=War>
    <td id=War>
           - <a href=index.php?p=REW.list class=menu target=game>List Rewards</a><br>
           - <a href=index.php?p=REW.place class=menu target=game>Place Reward</a><br>
           - <a href=index.php?p=kill class=menu target=game>Murder</a><br>
           - <a href=index.php?p=safety class=menu target=game>Buy Out Safety</a><br>
          </td>
</tr>
<?
} 
?>

<th class=kop><a href=# onclick="showMenu('Crews')">Crews</a></th>
<tr id=Crews>
    <td id=Crews>
    ?>
if($this_user['rank'] => 14 && $this_user['crew'] == 0) {
?>

        - <a href=index.php?p=CREW.start target=game>Start Crew</a><br>
   <?
     }
         elseif($this_user['crewrights[0]'] == '1' && $this_user['crew'] != 0) {
     ?>
    - <a href=online.php target=game>Users online</a><br>
<?
}
?>

        - <a href=paper.php target=game alt=>Gangsta World Daily</a><br>
        - <a href=donate.php target=game >Donations</a><br>
        - <a href=sponsors.php target=game >Sponsors</a><br>
          - <a href=edit.php target=game >Personal</a><br>
        - <a href=find.php target=game >Find user</a><br>
        - <a href=kill.php target=game >Kill</a><br>
        - <a href=attempts.php target=game>Attempts</a><br>
        - <a href=airport.php target=game >Airport</a><br>
        - <a href=cont.php target=game>Countries</a><br>
        - <a href=crew.php target=game>Crew</a><br>
        - <a href=shop.php target=game>Shop</a><br>
        - <a href=bullet.php target=game>Bulletfactory</a><Br>
        - <a href=jail.php target=game>Jail</a><br>
    </td>
</tr>



</table>

 

please tell me wat's wrong in if statment

Link to comment
https://forums.phpfreaks.com/topic/48828-minimize-menu/
Share on other sites

Where you have

 

?>

if($this_user['rank'] => 14 && $this_user['crew'] == 0) {

 

it should be

 

<?

if($this_user['rank'] >= 14 && $this_user['crew'] == 0) {

 

You drop in and out of PHP so often tht such errors aren't surprising.

 

 

 

Also, line 90, you have unmatched ( and )

 

if(!(safety($user['id'] == -1 && $user['safety'] == 1)){

 

Link to comment
https://forums.phpfreaks.com/topic/48828-minimize-menu/#findComment-239324
Share on other sites

Basically what Barand said but also

 

    - <a href=index.php?p=forum&fid=$for['id']><? echo $for['name'] ?></a></br>

 

 

 

Full code below

<center>
<script language="javascript">
function showMenu(id) {
  if(document.getElementById(id).style.visibility == "hidden") {
    document.getElementById(id).style.position      = "static";
    document.getElementById(id).style.visibility    = "visible";
  }
  else {
    document.getElementById(id).style.visibility    = "hidden";
    document.getElementById(id).style.position      = "absolute";
    document.getElementById(id).style.left      = -100;
    document.getElementById(id).style.top       = -100;
  }

  document.getElementById('mainTable').height       = '100%';
}
</script>
<?php
ob_start();
include("db.php");

?>
<link rel=stylesheet href=in.css>

<?php
$username = $_COOKIE['username'];
$sql = MySql_Query("SELECT * FROM users WHERE username = '".$username."'");
$user = MySql_Fetch_Array($sql);
?>
<center>
<table border=1 bordercolor=#000000 cellpadding=0 cellspacing=0 width=90%>
<th class=kop><a href=# onclick="showMenu('Earning')">Earning</a></th>
<tr id=Earning>
    <td id=Earning>

        - <a href=index.php?p=uCrime target=game alt="Do Crimes In The Omen World">Crimes</a><br>
        - <a href=index.php?p=trade target=game alt="Make Trade & Deceive PPL
">Trading</a><br>
        - <a href=index.php?p=bank target=game alt="This is the Gangsta World newspaper.">Bank</a><br>
    </td>
</tr>

<th class=kop><a href=# onclick="showMenu('traveling')">Traveling</a></th>

<tr id=traveling>
    <td id=traveling>
    - <a href=index.php?p=travel class=menu target=game>Travel</a><br>
    - <a href=index.php?p=vehicle class=menu target=game>Vehicles</a><br>
    
    </td>
</tr>

<th class=kop><a href=# onclick="showMenu('Gambling')">Gambling</a></th>
<tr id=Gambling>
    <td id=gambling>
           - <a href=index.php?p=rps class=menu target=game>Rock, Paper, Scissors</a><br>
           - <a href=index.php?p=rr class=menu target=game>Russian Roulette</a><br>
           - <a href=index.php?p=slot class=menu target=game>Slot</a><br>
           - <a href=index.php?p=Dice class=menu target=game>Dice</a><br>
           - <a href=index.php?p=gan class=menu target=game>Guess Numbers</a><br>
           - <a href=index.php?p=lottery class=menu target=game>Lottery</a><br>
    </td>
</tr>
<th class=kop><a href=# onclick="showMenu('Forum')">Forum</a></th>
<tr id=forum>
<td id=forum>
<?php
if($this_user['crew'] != 0) {
  ?>
    
- <a href=index.php?p=crewforum&fid=$user['crew'] class=menu target=_parent>Crew Forum</a><br>
  <?php  
  }
     elseif($user['rank'] >= 99) {
   	?>
    - <a href=index.php?p=forum&fid=-1 class=menu target=game>Admin</a><br>
  
    <?php
    }

     $q = mysql_query("SELECT * FROM forum WHERE crew = 0");
     $for = mysql_fetch_object($q) 
       
    ?>
    - <a href=index.php?p=forum&fid=$for['id']><?php echo $for['name'] ?></a></br>
    </td>
</tr>
<?php
  if( !(safety($user['id'] == -1) && $user['safety'] == 1) )
  {
  	?>
<th class=kop><a href=# onclick="showMenu('war')">War</a></th>
<tr id=War>
    <td id=War>
           - <a href=index.php?p=REW.list class=menu target=game>List Rewards</a><br>
           - <a href=index.php?p=REW.place class=menu target=game>Place Reward</a><br>
           - <a href=index.php?p=kill class=menu target=game>Murder</a><br>
           - <a href=index.php?p=safety class=menu target=game>Buy Out Safety</a><br>
          </td>
</tr>
<?php
} 
?>

<th class=kop><a href=# onclick="showMenu('Crews')">Crews</a></th>
<tr id=Crews>
    <td id=Crews>
    <?php
if($this_user['rank'] >= 14 && $this_user['crew'] == 0) {
?>

        - <a href=index.php?p=CREW.start target=game>Start Crew</a><br>
   <?php
     }
         elseif($this_user['crewrights[0]'] == '1' && $this_user['crew'] != 0) {
     ?>
    - <a href=online.php target=game>Users online</a><br>
<?php
}
?>

        - <a href=paper.php target=game alt=>Gangsta World Daily</a><br>
        - <a href=donate.php target=game >Donations</a><br>
        - <a href=sponsors.php target=game >Sponsors</a><br>
          - <a href=edit.php target=game >Personal</a><br>
        - <a href=find.php target=game >Find user</a><br>
        - <a href=kill.php target=game >Kill</a><br>
        - <a href=attempts.php target=game>Attempts</a><br>
        - <a href=airport.php target=game >Airport</a><br>
        - <a href=cont.php target=game>Countries</a><br>
        - <a href=crew.php target=game>Crew</a><br>
        - <a href=shop.php target=game>Shop</a><br>
        - <a href=bullet.php target=game>Bulletfactory</a><Br>
        - <a href=jail.php target=game>Jail</a><br>
    </td>
</tr>



</table>

 

 

EDIT replaced <? with  <?php (looks cleaner)

Link to comment
https://forums.phpfreaks.com/topic/48828-minimize-menu/#findComment-239332
Share on other sites

What you have posted is a "rats-nest" of code, jumping in and out PHP almost every other line, with some of the PHP code outside PHP tags (such as that if() statement). Also you are apparently interchanging variable names at random.

 

$this_user=$user

 

Given that

 

we can't run the code (we dont have your database)

you only say "it gives an error" without even saying what the error is,

we don't even know if you implemented all the suggestions offered so far

 

 

are you really surprised the responses aren't flooding in?

Link to comment
https://forums.phpfreaks.com/topic/48828-minimize-menu/#findComment-240918
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.