error ------->Notice: Undefined variable: result in C:\wamp\www\

<?php
include(db.php);
?>
<table>
<tr>
<td>Select Project:*</td>
<td>
<select name="project_id" id="project_id">
<?php
echo project_name($con);
?>
</select>
</td></tr>
</table>

function project_name($con){
    $select = mysqli_query($con,"select 
    projects.project_id,
    projects.project_name,
    user_proj.user_id,
    user_proj.project_id
    from 
    projects projects,
    users_projects user_proj 
    where 
    projects.project_id = user_proj.project_id and  
    user_proj.user_id ='".$_SESSION['user_id']."'");

while($row = mysqli_fetch_array($select)){
    $result .='<option value="'.$row['project_id'].'">'.$row['project_name'].'</option>';
    }
        return $result;
}

Thank you so much...it worked But why should we add this $result = '';

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.