Web Analytics Made Easy -
StatCounter struggling with show and hide - CodingForum

Announcement

Collapse
No announcement yet.

struggling with show and hide

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • struggling with show and hide

    I have been working on this for some time and Im very confused, Im use to VB, but here goes.
    I wish to hide a feature/text label if a person is of a different package type and show a button/feature if he is of package 'letmein'

    Its in 4 parts

    Part 1
    This works OK but i feel i will need to add code where indicated.******here**** to make it work using &&


    <?
    $has_blog = Q("SELECT count(userid) AS result FROM frm_blog WHERE userid=".$_REQUEST['id'],$connector);
    if($has_blog ==1 && ****here****){
    $display_blog = Q("SELECT sum(d_profile) AS result FROM frm_blog WHERE userid=".$_REQUEST['id'],$connector);
    }else{
    $display_blog = 0;
    }
    if(USER_BLOG ==1 && $has_blog ==1 && $display_blog ==1){ ?>


    Part 2
    This shows a text lable <? print $Language['Blog']['MyProfile']; ?> works OK


    Part 3 this returns and prints the package name as a string OK.

    <?php $result = @mysql_query("select gName as accountpackage from frm_groups where groupid=".$_SESSION['groupid']); $row = @mysql_fetch_object($result); $accountpackage = $row->accountpackage; echo $accountpackage;?>



    Part 4

    The bit im struggling with which i think will have to go in part 1 is here.

    if i add something like ( //trying to compare two string values so if aperson id of type 'letmeinPackage the text label/feature will show.

    <?php $packageName = 'letmeinPackage' ;
    If ($result ==$package) {
    then show print $Language['Blog']['MyProfile'];
    }
    else
    { hide print $Language['Blog']['MyProfile']; }
    ?>

    This code would then be added to part 1 some how, or may be on its own.

    Any help will be fantastic.

    Sorry of the syntax

  • #2
    welcome here!

    i didn't realy unbderstand much of your explanation, but isn't the
    <?php $packageName = 'letmeinPackage' ;
    If ($result ==$package) {
    then show print $Language['Blog']['MyProfile'];
    }
    else
    { hide print $Language['Blog']['MyProfile']; }
    ?>

    not simply
    PHP Code:
    <?php 
    $packageName 
    'letmeinPackage' 
    If (
    $result == $packageName) {
        print 
    $Language['Blog']['MyProfile']; 
    }
    ?>
    as an aside: it's kind of a php-coders convention to use $result for storing the resourceID of a query in it...
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

    Comment


    • #3
      Thanks for that

      I can make the label dissappear, however no package can see it then, therefore its not reading the string value correctly i guess. i have this so far.

      <? } ?>
      <?
      $has_blog = Q("SELECT count(userid) AS result FROM frm_blog WHERE userid=".$_REQUEST['id'],$connector);
      if($has_blog ==1){
      $display_blog = Q("SELECT sum(d_profile) AS result FROM frm_blog WHERE userid=".$_REQUEST['id'],$connector);
      }else{
      $display_blog = 0;
      }
      if(USER_BLOG ==1 && $has_blog ==1 && $display_blog ==1){ ?>
      </td>
      <td width="1%"><img src="<? print "http://".DB_DIRC."/templates/".D_TEMP."/images/"; ?>layout/ac_6s.gif" width="16" height="16"></td>
      <td width="16%" class="menu_text"><a href="blog.php?id=<? print $_REQUEST['id']; ?>" style="font-size: 13px"><?php
      $result = @mysql_query("select gName as accountpackage from frm_groups where groupid=".$_SESSION['groupid']); $row = @mysql_fetch_object($result); $accountpackage = $row->accountpackage; echo $accountpackage;
      $packageName = "On-Line+" ;
      If ($result == $packageName) {
      print $Language['Blog']['MyProfile'];
      }

      ?> </a>
      <? } ?>

      Comment


      • #4
        If ($result == $packageName) {

        can never evaluate to True, because $result will just contain the resourceID (like "1" or so ).
        so what do you want to compare to $packageName?
        Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

        Comment


        • #5
          Thanks again here goes again

          If I use the following code:
          Your members status is: <span class="ac_memberlevel">
          <?php $result = @mysql_query("select gName as accountpackage from frm_groups where groupid=".$_SESSION['groupid']); $row = @mysql_fetch_object($result); $accountpackage = $row->accountpackage; echo $accountpackage;?>
          </span></div> </td>

          Its returns Gold membership as a text

          I assummed that that text could be compared against another?

          Comment


          • #6
            Here is another version that returns teh string texy gold member

            $result = @mysql_query("select gName as accountpackage from frm_groups where groupid =".$DATA[15]);
            $row = @mysql_fetch_object($result);
            $accountpackage = $row->accountpackage; print $accountpackage;

            $packageName = 'gold member' ;
            If ($result == $packageName) {
            print $Language['Blog']['MyProfile'];
            }
            ?> </a>
            <? } ?>


            this keeps showing gold member ?

            if this is a gold member don't show print $Language['Blog']['MyProfile']; ?

            Comment


            • #7
              slowly getting there

              Im hoping that you maybe able to help me here.


              What I am trying to do is this, i have many memberships, all members have blogs but i only want 'online+' to be able to view them. If a member of 'silver' membership tries to view the blog the label/text will be missing.

              at the moment it prints both

              so...

              <?
              $result = @mysql_query("select gName as accountpackage from frm_groups where groupid =".$DATA[15]);
              $row = @mysql_fetch_object($result);
              $accountpackage = $row->accountpackage; print $accountpackage;
              prints the text 'ONLINE+' member

              in fact print $accountpackage; does it


              If ($accountpackage == 'On-Line') {
              print $Language['Blog']['MyProfile']; (this prints Blog)
              }
              else{
              print ' ';
              }


              what it seems to do is print both.....

              any ideas please

              Comment


              • #8
                i can't realy say more then i already did...
                your code should in my opinion be changed to:
                PHP Code:
                $result = @mysql_query("select gName as accountpackage from frm_groups where groupid =".$DATA[15]); 
                $row = @mysql_fetch_object($result); 
                $accountpackage $row->accountpackage;
                If (
                $accountpackage == 'gold member') { 
                   print 
                $Language['Blog']['MyProfile']; 

                but i would personally script it like
                PHP Code:
                $result = @mysql_query("select gName from frm_groups where groupid =".$DATA[15]); 
                if (
                mysql_result($result0) == 'gold member') { 
                   print 
                $Language['Blog']['MyProfile']; 

                Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

                Comment

                Working...
                X