Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Quick If Statement Query

  • 31-01-2009 11:38AM
    #1
    Registered Users, Registered Users 2 Posts: 3,875 ✭✭✭


    Can anyone tell why this might not work?


    <?php if (($row_Recordset1 == "processing")){
    echo <a href="mgcancelcourse.php?registratrion=$farm">cancel</a> ; } ?>


    it is withing a table here is the full part, the first if statement works fine, but when i try and use the link i am having no luck, i can print the link just not as a hyperlink

    <?php $farm = $row_Recordset1; ?>

    <td> <?php if (($row_Recordset1 != "processing")){
    echo 'n/a' ; } ?>

    <?php if (($row_Recordset1 == "processing")){
    echo <a href="mgcancelcourse.php?registratrion=$farm">cancel</a> ; } ?>



    </td>


Comments

  • Closed Accounts Posts: 30 Mr. Magoo


    Can anyone tell why this might not work?


    <?php if (($row_Recordset1 == "processing")){
    echo <a href="mgcancelcourse.php?registratrion=$farm">cancel</a> ; } ?>


    it is withing a table here is the full part, the first if statement works fine, but when i try and use the link i am having no luck, i can print the link just not as a hyperlink

    <?php $farm = $row_Recordset1; ?>

    <td> <?php if (($row_Recordset1 != "processing")){
    echo 'n/a' ; } ?>

    <?php if (($row_Recordset1 == "processing")){
    echo <a href="mgcancelcourse.php?registratrion=$farm">cancel</a> ; } ?>



    </td>

    You're missing some quotes around the string you're trying to echo out.

    You have to wrap any string of text in single or double quotes. If you use double quotes PHP can parse the string to replace any variables with their value.

    [PHP]

    <?php
    if (($row_Recordset1 == "processing")){
    echo "<a href=\"mgcancelcourse.php?registratrion=$farm\">cancel</a>"; }
    ?>

    [/PHP]


  • Registered Users, Registered Users 2 Posts: 8,488 ✭✭✭Goodshape


    Your quotes seem to be missing / messed up.

    [php]
    <?php if (($row_Recordset1 == "processing")){
    echo "<a href=\"mgcancelcourse.php?registratrion=$farm\">cancel</a>"; } ?>
    [/php]

    ^^ try that.


    //edit
    D'oh! Too slow :)


  • Registered Users, Registered Users 2 Posts: 3,875 ✭✭✭ShoulderChip


    Perfect,
    thank you both very much.


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    Another way to write this could be:
    [php]
    <?php echo $row_Recordset1 == "processing" ? "<a href=\"mgcancelcourse.php?registratrion=$farm\">cancel</a>" : ""; ?>
    [/php]


Advertisement