Jump to content

function not showing result...


An7hony
 Share

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

Link to comment
Share on other sites

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;

}

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • 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.