An7hony Posted November 30, 2011 Share Posted November 30, 2011 Can anyone suggest a solution? function getOtherProject($worker) { $query2 = "SELECT company_project FROM projects WHERE username='$worker'"; $res = mysql_query($query2); while($a = mysql_fetch_array($res)) { echo "company_project = '".$a["company_project"]."' or "; } } getOtherProject($session->username); When called here reads: company_project = 'HTML' or company_project = 'Coder' or $query1 = "SELECT username, company, company_line_manager, firstname, lastname, level FROM work_users WHERE level = '4' and "; $query2 = getOtherProject($session->username); $query3 = "company_project = 'abc123'"; $query = $query1.$query2.$query3; $res = mysql_query($query, $cid); echo $query; [/code] When called here the function getOtherProject, get ignored: SELECT username, company, company_line_manager, firstname, lastname, level FROM work_users WHERE level = '4' and company_project = 'abc123' Quote Link to comment https://forums.phpfreaks.com/topic/252155-function-not-showing-result/ Share on other sites More sharing options...
An7hony Posted November 30, 2011 Author Share Posted November 30, 2011 if i use return it shows the, 'and company_project = 'HTML'' but not the full statement? function getOtherProject($worker) { $query2 = "SELECT company_project FROM projects WHERE username='$worker'"; $res = mysql_query($query2); while($a = mysql_fetch_array($res)) { return "company_project = '".$a["company_project"]."' or "; } } Quote Link to comment https://forums.phpfreaks.com/topic/252155-function-not-showing-result/#findComment-1292785 Share on other sites More sharing options...
An7hony Posted November 30, 2011 Author Share Posted November 30, 2011 this worked: function getOtherProject($worker) { $output = ''; $query2 = "SELECT company_project FROM projects WHERE username='$worker'"; $res = mysql_query($query2); while($a = mysql_fetch_array($res)) { $output .= "company_project = '".$a["company_project"]."' or "; } return $output; } Quote Link to comment https://forums.phpfreaks.com/topic/252155-function-not-showing-result/#findComment-1292787 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.