www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Server-Side Development > PHP

    PHP Discussion and technical support for using and deploying PHP based websites.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 07-03-2009, 04:31 PM
    ehime's Avatar
    ehime ehime is offline
    Screw Coding....
     
    Join Date: Oct 2008
    Location: Seattle, Wa
    Posts: 342
    Function woes...

    I can't remember why, but I know there was something I needed to do to
    get my function to grab the variables of my array. Sorry its the end of the
    day and I'm tired.

    PHP Code:
    <?php $token = uniqid(); $noko = array(0 => '0',1 => 'c12-',2 => 'CS-3412A',3 => ''); xBlocks (); ?>

    <?php
        
    function  xBlocks() {
            echo
    '<div class="k"><form action=\'\' name="ID_'.$token.'"> <p><img alt=\'\' class="pImg" name="imgBig_'.$token.'" src="'.$src.$noko[1].'01-m.jpg" /></p> <div class=\'ptext\'><a href="'.$url.$noko[1].'.php">'.$noko[2].'</a></div>';
            
    $a = $noko[0]; $b = $noko[0];
                echo
    '<div class="ico">';
                    
    $i = 1; $c = 0; while ($i <= $a):
                    
    $t = str_pad($i, 2, "0", STR_PAD_LEFT);
                        echo
    '<img alt=\'\' onMouseOver="roll(\''.$src.$noko[1].$i.'-m.jpg\',\''.$src.$noko[1].$i.'-m.jpg\',\''.$token.'\',\''.$c.'\');" src="'.$src.$noko[1].$i.'-ico.jpg" />'; $i++; $c++;
                    endwhile;
                    
                echo
    '</div><div class="arrow">';
                
                    if (
    $b > 0 ) { echo '<img alt=\'\' src="http://omnisistem.com/images/1up.gif" name="up_arrow_'.$token.'_0 />'; }
                
                
    $i = 1; while ($i <= $b):
                        echo
    '<img alt=\'\' src="http://omnisistem.com/images/pixel.gif" name="up_arrow_'.$token.'_'.$i.'" />'; $i++;
                    endwhile;
                    
                echo
    '<input type=\'hidden\' value="'.$noko[0].'" name="icoLength'.$token.'" /></div></form></div></div>';
        }
    ?>
    Reply With Quote
      #2  
    Old 07-03-2009, 05:48 PM
    svidgen's Avatar
    svidgen svidgen is offline
    Angry Stickman
     
    Join Date: Jan 2007
    Location: Wisconsin
    Posts: 800
    Your question is a bit ... ambiguous. Are you looking for this?
    PHP Code:
    global $noko;
    __________________
    Jon Wire
    Webmaster and Author of Ridiculousness

    why is the sun so hot? | fling poo! | Social Bookmarking (BETA (but still really bloody cool))
    Reply With Quote
      #3  
    Old 07-03-2009, 06:16 PM
    ehime's Avatar
    ehime ehime is offline
    Screw Coding....
     
    Join Date: Oct 2008
    Location: Seattle, Wa
    Posts: 342
    Quote:
    Originally Posted by svidgen View Post
    Your question is a bit ... ambiguous. Are you looking for this?
    PHP Code:
    global $noko;

    Something along those lines, unfortunately global $noko doesn't work since
    $noko is an array. But yeah, that's the gist of it. I use the array $noko a
    few times with different values, and would like to push those values into
    my function. If you take that code outside of the function it works great,
    unfortunately as soon as you stick it inside a function, the array $noko can
    not pass variables into it.
    Reply With Quote
      #4  
    Old 07-03-2009, 06:24 PM
    criterion9 criterion9 is offline
    Registered User
     
    Join Date: Jan 2009
    Posts: 1,145
    What is you required the $noko array as a parameter to your function as in: function_name($array_name) and then called your function with function_name($noko);?
    Reply With Quote
      #5  
    Old 07-03-2009, 06:28 PM
    svidgen's Avatar
    svidgen svidgen is offline
    Angry Stickman
     
    Join Date: Jan 2007
    Location: Wisconsin
    Posts: 800
    Quote:
    $noko doesn't work since $noko is an array.
    Global should work regardless of the variable type ...

    http://us2.php.net/manual/en/languag...bles.scope.php
    __________________
    Jon Wire
    Webmaster and Author of Ridiculousness

    why is the sun so hot? | fling poo! | Social Bookmarking (BETA (but still really bloody cool))

    Last edited by svidgen; 07-03-2009 at 06:29 PM. Reason: added link
    Reply With Quote
      #6  
    Old 07-04-2009, 12:14 AM
    ehime's Avatar
    ehime ehime is offline
    Screw Coding....
     
    Join Date: Oct 2008
    Location: Seattle, Wa
    Posts: 342
    /facepalm I put global outside my function....
    I'd thought there was something out of order.

    I tried it earlier, thought it was incompatible
    and moved on to something else entirely. I
    should have read the doc.


    Quick Question, is there anyway that this might
    be interfering with my javascript? I just got a
    weird js error about undefined variables.

    Last edited by ehime; 07-04-2009 at 12:30 AM.
    Reply With Quote
      #7  
    Old 07-04-2009, 06:38 PM
    JunkMale's Avatar
    JunkMale JunkMale is offline
    Registered User
     
    Join Date: Jan 2009
    Location: it is nice where I live.
    Posts: 496
    You put the "GLOBAL" variable you are refering to "INSIDE" the function.
    Reply With Quote
      #8  
    Old 07-04-2009, 07:06 PM
    ehime's Avatar
    ehime ehime is offline
    Screw Coding....
     
    Join Date: Oct 2008
    Location: Seattle, Wa
    Posts: 342
    Yah I figured that out....
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 11:29 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.