Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Quick If Statement Query

Options
  • 31-01-2009 12:38pm
    #1
    Registered Users 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 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 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