Multiple Selection

When I try to select more than one item in my list box only one value will show in the report(usually the last chosen). If I add [] to the name in the form and try to run the report I get an error…

Here’s the form code:


Job Type: ALL {section name=jt loop=$job_type_list} {$job_type_list[jt][1]} {/section} [/code]

Here’s the other code(sorry its kinda long):
[php]function execute_object($tab){
if ((isset($_POST[‘job’]) and
isset($_POST[‘job_type’]) and
isset($_POST[‘child_type’]) and
isset($_POST[‘job_status’]) and
isset($_POST[‘child_status’]) and
isset($_POST[‘ou’]) and
isset($_POST[‘child_ou’]) and
isset($_POST[‘pm’]) and
isset($_POST[‘child_pm’]) and
isset($_POST[‘dm’]) and
isset($_POST[‘child_dm’]) and
isset($_POST[‘customer’]) and
isset($_POST[‘end_date’])) or
(isset($_SESSION[‘report_job’]) and
isset($_SESSION[‘report_job_type’]) and
isset($_SESSION[‘report_child_type’]) and
isset($_SESSION[‘report_job_status’]) and
isset($_SESSION[‘report_child_status’]) and
isset($_SESSION[‘report_ou’]) and
isset($_SESSION[‘report_child_ou’]) and
isset($_SESSION[‘report_pm’]) and
isset($_SESSION[‘report_child_pm’]) and
isset($_SESSION[‘report_dm’]) and
isset($_SESSION[‘report_child_dm’]) and
isset($_SESSION[‘report_customer’]) and
//Include functions
include $GLOBALS[‘include_path’].“penta.job.functions.php”;
include $GLOBALS[‘include_path’].“display.functions.php”;
include $GLOBALS[‘include_path’].“report.functions.php”;

	//Get report parameters
	if (isset($_POST['job'])){
		$job_id = $_POST['job'];
	} else {
		$job_id = $_SESSION['report_job'];
	if (isset($_POST['job_type'])){
		$job_type = $_POST['job_type'];
	} else {
		$job_type= $_SESSION['report_job_type'];
	if (isset($_POST['child_type'])){
		$child_type = $_POST['child_type'];
	} else {
		$child_type= $_SESSION['report_child_type'];
	if (isset($_POST['exclude_type'])){
		$exclude_type = 1;
	} else {
			$exclude_type = $_SESSION['report_exclude_type'];
		} else {
			$exclude_type = 0;
	if (isset($_POST['job_status'])){
		$job_status = $_POST['job_status'];
	} else {
		$job_status= $_SESSION['report_job_status'];
	if (isset($_POST['child_status'])){
		$child_status = $_POST['child_status'];
	} else {
		$child_status= $_SESSION['report_child_status'];
	if (isset($_POST['ou'])){
		$ou_id = $_POST['ou'];
	} else {
		$ou_id = $_SESSION['report_ou'];
	if (isset($_POST['child_ou'])){
		$child_ou_id = $_POST['child_ou'];
	} else {
		$child_ou_id = $_SESSION['report_child_ou'];
	if (isset($_POST['pm'])){
		$pm_id = $_POST['pm'];
	} else {
		$pm_id = $_SESSION['report_pm'];
	if (isset($_POST['child_pm'])){
		$child_pm_id = $_POST['child_pm'];
	} else {
		$child_pm_id = $_SESSION['report_child_pm'];
	if (isset($_POST['dm'])){
		$dm_id = $_POST['dm'];
	} else {
		$dm_id = $_SESSION['report_dm'];
	if (isset($_POST['child_dm'])){
		$child_dm_id = $_POST['child_dm'];
	} else {
		$child_dm_id = $_SESSION['report_child_dm'];
	if (isset($_POST['customer'])){
		$cus_id = $_POST['customer'];
	} else {
		$cus_id = $_SESSION['report_customer'];
	if (isset($_POST['sort_by_cust'])){
		$sort_by_cust = 1;
	} else {
			$sort_by_cust = $_SESSION['report_sort_by_cust'];
		} else {
			$sort_by_cust = 0;
	if (isset($_POST['end_date'])){
		$edate = $_POST['end_date'];
	} else {
		$edate = $_SESSION['report_end_date'];
	//$job_type = implode(",",$_POST['job_type']);
	//Prepare to output report
	$filename = "Project Review Report.xls";
	if (isset($_POST['print'])){
		//Prepare the output file
		header("Content-type: application/");
		header("Content-Disposition: attachment; filename=\"$filename\"");
		header("Expires: 0");
		header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
		header("Pragma: public");
	} else {
		//Save the report parameters to enable printing from the preview
		$_SESSION['report_job'] = $job_id;
		$_SESSION['report_job_type'] = $job_type;
		$_SESSION['report_child_type'] = $child_type;
		$_SESSION['report_exclude_type'] = $exclude_type;
		$_SESSION['report_job_status'] = $job_status;
		$_SESSION['report_child_status'] = $child_status;
		$_SESSION['report_ou'] = $ou_id;
		$_SESSION['report_child_ou'] = $child_ou_id;
		$_SESSION['report_pm'] = $pm_id;
		$_SESSION['report_child_pm'] = $child_pm_id;
		$_SESSION['report_dm'] = $dm_id;
		$_SESSION['report_child_dm'] = $child_dm_id;
		$_SESSION['report_customer'] = $cus_id;
		$_SESSION['report_sort_by_cust'] = $sort_by_cust;
		$_SESSION['report_end_date'] = $edate;
		//Output a print button at the start of the preview
	//Get the list of jobs based on the given criteria
	$job_list = report_job_list($job_id, $job_type, $child_type, $exclude_type, $job_status, $child_status, $ou_id, $child_ou_id, $pm_id, $child_pm_id, $dm_id, $child_dm_id, $cus_id, $sort_by_cust, $selected_by);
	//Set the max script execution time to ensure it can finish based on the number of jobs
	$num_jobs = $job_list->RecordCount();
	set_time_limit(60 + ($num_jobs * 30));
	//Parse the template
	$template = $GLOBALS['reports_path']."report52.2.htm";
	$default_logo = "report52.2_files/image001.gif";
	$hdr = null; $ftr = null;
	parse_template($template, $default_logo, $hdr, $ftr);

Hi there,

I would guess that the error is probably due to the fact that $_POST[‘job_type’] will be returning an array when you add [] to the name. This is probably causing problems elsewhere in the code where it is expecting a string and using functions that do not work for arrays.

Use error_reporting(E_ALL); at the top of your page and see what exactly the error is and where - you may just be able to set $job_type = implode(",",$_POST[‘job_type’]);

Let us know what exactly the error is when you add the [] because that is what you are going to need to do in order to retrieve all the selections.

Thanks. I did what you said and I received this error.

Fatal error: Call to a member function RecordCount() on a non-object in object

My log file had this:
SQL failed:exception ‘ADODB_Exception’ with message 'oci8 error: [904: ORA-00904: “ARRAY”: invalid identifier].

If I remove the [] from the name=job_type and attempt to run. The report runs but gives me shows all the selection instead of the two I chose.

I think the RecordCount() is failing because report_job_list() is returning false. I would imagine that this is because with the [] in place, $job_type is an array whereas the function may have been written to expect a string as this parameter. Check what report_job_list() does with the second parameter - it may need modification in order to allow an array to be passed to it.

Ok. My error log file has this…

Stack trace:

#4 report_job_list(‘0’, Array, ‘0’, 0, ‘’, ‘’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, 0, ‘Job Type: | Sor…’)

The zero’s are correct the ‘Array’ value is still causing this problem.

Here is a portion of the function that includes the $job_type: (the portion not shown follows pretty much the same pattern.)
[php]//Get list of parent/stand-alone jobs for project review report
function report_job_list($job_id, $job_type, $child_type, $exclude_type, $job_status, $child_status, $ou_id, $child_ou_id, $pm_id, $child_pm_id, $dm_id, $child_dm_id, $cus_id, $sort_by_cust, &$selected_by){
//Initialize the ‘filtered by’ return
$selected_by = “”;
$where_started = 0;

//Build the query based on the given parameters
$sql = "select job.job_id as ID, as NAME,
		 job.cus_id AS CUS_ID, AS CUS_NAME,
		 job.par_job_id as PARENT_ID
		from job
		 join customer on job.cus_id = customer.cus_id";
if ($job_id != 0){
	//Get the specified job
	$sql .= " where job.job_id = ".$job_id;
	$selected_by = "Job ".$job_id;
} else {
	//Get the selected jobs
	if ($job_type != 0){
		if ($exclude_type){
			$sql .= " where job.jt_cd != ".$job_type;
			$where_started = 1;
			$selected_by = "NOT Job Type:".get_job_type_descr($job_type);
		} else {
			$sql .= " where job.jt_cd = ".$job_type;
			$where_started = 1;
			$selected_by = "Job Type:".get_job_type_descr($job_type);
	} [/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service