Page 1 of 1

[SOLVED] $num_results is empty

Posted: Mon Nov 03, 2003 3:00 pm
by brewmiser
I am on the verge of jumping of the roof of my building....please help!! :lol:

Why does this function not work? It is dieing around the num_results. Why?

Code: Select all

<?php 
function  pe($input_id) {
  $sql_pe = "SELECT
				employee_role_id,
				cal_firstname,
				cal_lastname,
				cal_extension
				FROM project_employees, webcal_user
				WHERE project_employees.project_id = '".$id_project."' AND project_employees.cal_login = webcal_user.cal_login";
  $query_pe = mysql_query($sql_pe) or die("<b>MySQL Error 11:</b> ".mysql_errno()." : ".mysql_error());
  $num_results_pe = mysql_num_rows($query_pe);
	$x=0;
	echo $num_results_pe;
	while ($x<$num_results_pe) {
	  $array_pe = mysql_fetch_array($query_pe);
		$first_name = $array_pe['cal_firstname'];
		$last_name = $array_pe['cal_lastname'];
		$extension = $array_pe['cal_extension'];
		$role_id = $array_pe['employee_role_id'];
		if ($role_id == "$input_id") {
		  echo "<p>".$first_name." ".$last_name." (ext. ".$extension.")</p>";
		}
	  $x++;
	}
}
?>
Help!

Posted: Mon Nov 03, 2003 3:24 pm
by brewmiser
Nevermind. I saved my own life.

I had to specify the global variable $id_project inside the function.

Sorry, and thanks. :oops: