/    Sign up×
Community /Pin to ProfileBookmark

How to call a function using Echo?

I have this function:

[LIST]

  • [*]

    getbgc()


  • [/LIST]

    I’m trying to call it using an echo statement, but I can’t seem to get it right. Here’s what I have:

    [code=php]echo “<tr style=”.getbgc($i).”>
    <td style=’width:auto’>”.$row[0].”</td>
    <td style=’width:auto’>”.$row[1].”</td>
    … etc[/code]

    To me, that looks right. But it isn’t being called. The function only serves to alternate two colors on the table rows, but they stay white throughout. Can anyone tell me what I’m doing wrong here?

    to post a comment
    PHP

    6 Comments(s)

    Copy linkTweet thisAlerts:
    @ginerjmDec 02.2015 — 1 - do you have error checking turned on?

    2 - does this function return a scalar value?

    3 - if you would begin to use css, making that width:auto a td setting would save you a lot of needless typing.
    Copy linkTweet thisAlerts:
    @NogDogDec 02.2015 — What you have looks fine -- assuming the function actually returns something? I.e.: you want it to return the string to be output, not do an echo inside the function itself.
    Copy linkTweet thisAlerts:
    @sagacademyDec 07.2015 — Try this code

    function header(){

    echo "

    <script src='<?php echo node_dir ?>/nav.min.js'></script>

    ";

    }

    I can call this node_dir function from within a php echo, or alternately output:

    <script src='<?php echo node_dir ?>/nav.min.js'></script>

    from the header function.

    Get PHP Training in Jaipur
    Copy linkTweet thisAlerts:
    @OrigiinDec 07.2015 — How to call a function using Echo?

    <?php

    if ( isset($_GET['pmd']) ) {

    echo"<div class="response"><p style="width:350px; height:200px; vertical-align:middle;"><strong>Thank you for acting as a &quot;watchman on the walls&quot; of Jerusalem! Your name will now appear on our virtual wall.<br><br>You can also catch up on the latest news from Israel by visiting our news feed below.</strong></p></div>";

    }else { etc...
    Copy linkTweet thisAlerts:
    @ginerjmDec 07.2015 — Ummm, where is the function call in your example, Origin?
    Copy linkTweet thisAlerts:
    @kite123Jan 01.2016 — hey,try this code:

    <?php if ( isset($_GET['pmd']) ): ?>

    <div class="response"><p style="width:350px; height:200px; vertical-align:middle;"><strong>Thank you for acting as a &quot;watchman on the walls&quot; of Jerusalem! Your name will now appear on our virtual wall.<br><br>You can also catch up on the latest news from Israel by visiting our news feed below.</strong></p>

    <br />

    <img src="url.com?cid=12345&aid=1234&oid=<?php echo mt_rand(); ?>&quantity=1" height="1" width="1" />

    </div>

    <?php else: ?>

    etc

    <?php endif; ?>
    ×

    Success!

    Help @Landslyde spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.18,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...