PHP conditional loop help

Posted by sea_1987 on Stack Overflow See other posts from Stack Overflow or by sea_1987
Published on 2010-04-16T08:48:19Z Indexed on 2010/04/16 8:53 UTC
Read the original article Hit count: 267

Filed under:
|
|
|

Hi there in my database I have 3 columns, is_contract, is_permenant and is_temporary. Within these columns there is either a Y or N value.

I am using these columns to echo onto the page what kind of work someone is looking for, my problem is that the user can be looking for more than one type of work, I am currently running 3 if statements to determine what to echo to the page, however I am struggling to add a comma if more than one of the statemnts returns as true, below is my code so far,

<?php
    if($rslt['is_contract'] == 'Y') {
        echo "Contract ";
}
    if($rslt['is_permanent'] == 'Y') {
        echo "Permanent ";
}
if($rslt['is_temporary'] == 'Y') {
    echo "Temporary";
}
?>

© Stack Overflow or respective owner

Related posts about php

Related posts about conditionals