Jump to content

function not showing result...


An7hony

Recommended Posts

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'

Link to comment
https://forums.phpfreaks.com/topic/252155-function-not-showing-result/
Share on other sites

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 ";
}
  }

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;

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.