Multiple SELECT ???? impossible? arrays?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hdogg
Forum Newbie
Posts: 13
Joined: Fri Apr 06, 2007 10:39 am

Multiple SELECT ???? impossible? arrays?

Post by hdogg »

Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi I am trying to populate a table.... with the Jobcode on column one, column 1 thru 12 are months...

so it would display the forecast for each month for each jobcode.

Code: Select all

/// Select job codes 
$query_select_job_codes = oci_parse($c, "((SELECT JOB_CODE AS JOBCODE FROM GSI.PCTCOMP_ACC_VW WHERE ( PCT_DATE = TO_DATE('20070228000000','YYYYMMDDHH24MISS') ) AND ( PCT_COMP_CODE = '02' ))  )");
$query_select_all = oci_parse($c, "SELECT * FROM FORECAST_INPUT");


echo 
'<table>
<tr><td>Year: 20-- </td></tr>
<tr><TD></td><TD>Jan</td><td>Feb</td><TD>Mar</td><TD>Apr</td><TD>May</td><TD>June</td><TD>July</td><TD>Aug</td><TD>Sep</td><TD>Oct</td><TD>Nov</td><TD>Dec</td></tr>
<tr><TD>Job Code</td></tr>';

echo 

/// Select forecast amounts
$query_select_forecast = oci_parse($c, "SELECT * FROM FORECAST_INPUT 
	WHERE JOBCODE = '%$jobcode%' ORDER BY JOBCODE ASC");

		oci_execute($query_gsi);
	while($res=oci_fetch_array($query_gsi))
{
	$jobcode = $res['JOBCODE'];
	echo '<tr><td>'.$jobcode.'</td><tr>';
	
	oci_execute($query_select_forecast);
while($res=oci_fetch_array($query_select_forecast))	
	{
		$forecast = $res['FORECAST'];
		echo '<td>'.$forecast.'<td>';
	
	}
	echo 'jobcode';


-Hyrum


Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

Use SQL JOIN syntax to get all the data you need from both the jobcode and forecase_input tables.

Also, please use proper syntax highlighting and indents for your code.
hdogg
Forum Newbie
Posts: 13
Joined: Fri Apr 06, 2007 10:39 am

Post by hdogg »

Two Tables:

Table A: Columns - Jobcode, Forecast Amount
Table B Columns - Jobcode, Date

I want to display a report with Job Codes on the left and the forecast for the next 12 months going across.

ie. the report would have

Job Code , Jan, feb, mar, etc

So I want one query to select all relevant job codes from table B. JOBCODE.TableB

The second query would Select the forecasts pertaining to JOBCODE.TableB hence, ForecastedAmount.TableA for JOBCODE.TableB

I would prefer to do it by outputting two queries at once with some sort of nest

-Hyrum
Post Reply