Jump to content

toggle menu help (logic problem)


Q695

Recommended Posts

the menu code:

    <?php
    if ($u_row[char_mnu]=1){
    echo "
    <a href='?page=menus&contract=char_mnu&type=charicter'>Character</a>
    	<br>
    working
    ";
    }
else if($u_row[char_mnu]=0){
echo "
    <a href='?page=menus&expand=char_mnu&type=charicter'>Character</a>
    ";
}
    ?>

 

operating code:

<?php
$expand=$_GET[expand];
$contract=$_GET[contract];
if($expand){
$sql="UPDATE players SET $expand = '1' WHERE id='$id' ;";

}
if($contract){
$sql="UPDATE players SET $contract = '0' WHERE id='$id' ;";

}

echo $sql;
?>
<form name='wipe' method='get'>
<input type='hidden' name='page' value="<?php echo $_GET[type] ;?>">//page address info
</form>
<script>
document.wipe.submit();
</script>

 

The bug is a logic issue, but I don't know what I'm doing wrong.

Link to comment
https://forums.phpfreaks.com/topic/165310-toggle-menu-help-logic-problem/
Share on other sites

if ($u_row[char_mnu]=1){

 

and

 

else if($u_row[char_mnu]=0){

 

are assigning values, which will always return true (which is why haku wanted to you echo them out)

 

 

They need to be changed to:

 

if ($u_row[char_mnu]==1){

 

and

 

else if($u_row[char_mnu]==0){

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.