For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > August 2004 > problem with next page and queries









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author problem with next page and queries
justme@nospam.wanadoo.be

2004-08-22, 8:57 pm

Dears
I have created the following page to display my data

<head>
<style type="text/css">
body, td, th, h1, h2 {font-family: sans-serif;}
body, td, th {font-size: 100%;}
a:link { font-weight:bold; color:E00000; text-decoration:none }
a:visited { font-weight:bold; color:E00000; text-decoration:none }
a:hover { font-weight:bold; color:#E00000; text-decoration:none }
a:active { font-weight:bold; color:#F00000; text-decoration:none }
a:focus { font-weight:bold; color:#E00000; text-decoration:none }
..text1 {font-family: Arial, Helvetica, sans-serif;font-size:
16px;color: White;text-align : left;}
</style>
<script language="javascript">
function call(location)
{
url = new String(parent.sub.location.href);
arrayOfStrings = url.split('#');
parent.sub.location = arrayOfStrings[0] + location;
return false;
}
</script>
</head>

<body bgcolor="#777888">

<?

include "datas/connection_data.php";
include "datas/connect.php";
include "datas/stats2.php";

$Dblnk=connect ();

if ($res=send_sql($Data_Base, $Year))

{
while ($row = mysql_fetch_row ($res))
{
$Line1 = $Line1.$row[0]." <BR>";
}
}


?>

<TABLE bgcolor="#777888" border="1" width="100%">
<TR>
<TD align="center" colspan="22" bgcolor="grey"><B><FONT
size="+2">Rem amount POR</FONT></B></TD></TR>
<TR>
<TD align="center" colspan="1"><B>Dealer</B></TD>
<TD align="center" colspan="1"><B>Jan2004</B></TD>
<TD align="center" colspan="1"><B>Feb2004</B></TD>
<TD align="center" colspan="1"><B>Mar2004</B></TD>
<TD align="center" colspan="1"><B>Apr2004</B></TD>
<TD align="center" colspan="1"><B>MAY2004</B></TD>
<TD align="center" colspan="1"><B>JUN2004</B></TD>
<TD align="center" colspan="1"><B>JUL2004</B></TD>
<TD align="center" colspan="1"><B>AUG2004</B></TD>
<TD align="center" colspan="1"><B>Sep2004</B></TD>
<TD align="center" colspan="1"><B>OCT2004</B></TD>
<TD align="center" colspan="1"><B>NOV2004</B></TD>
<TD align="center" colspan="1"><B>Dec2004</B></TD>
<TD align="center" colspan="1"><B>Totaal</B></TD>
<TR align="center">
<TD width="10%">Dealer</TD>
<TD width="10%">Amount</TD>
<TD width="10%">Amount</TD>
<TD width="10%">Amount</TD>
<TD width="10%">Amount</TD>
<TD width="10%">Amount</TD>
<TD width="10%">Amount</TD>
<TD width="10%">Amount</TD>
<TD width="10%">Amount</TD>
<TD width="10%">Amount</TD>
<TD width="10%">Amount</TD>
<TD width="10%">Amount</TD>
<TD width="10%">Amount</TD>
<TD width="10%">Amount</TD></TD>
</TR>
<TR>
<TD width="10%"><? echo "$Line1" ?></TD></TR>

</TR>
</TABLE>


the Queries that I want to use in this page are the following 2
Queries

the first one is to display the data mentioned here <? echo "$Line1"
?> and contains the following Query
$Year = "SELECT DISTINCT DEALER_REM FROM ELEC_REM_NOTE WHERE
CURRENT_MONTH like '%2004'group by Dealer_rem";

the second type of query I want to use is this one

$Query = "SELECT DISTINCT DEALER_REM ,SUM(TOTAL_REM_AMOUNT) FROM
ELEC_REM_NOTE WHERE CURRENT_MONTH ='JAN2004'AND BLOC_ID
IN(1,2,3,4,5,7,8,10,12) group by Dealer_rem";


the problem that I have is that the result that I get from Query 2 has
to match the result of Query 1

example :

the table that I have as mentioned above is

Dealer January February March April ect.

I have 2 salesman working for me in January ED and Bert, Ed Sold 3
computers and Bert 5.
IN February I hire another salesman to keep up with the workload his
name is Charley
Ed Sells in February 4 Computers Bert 6 and Charley 5
In March Ed Is leaving the company and I hire a new guy named Pete to
replace Ed.
Bert sells 7 Computers Charley 6 and Pete 3



when I run the first Query the result will be Bert, Charley, Ed, and
Pete.

the result of the second Query has to be displayed in the following
way:

Dealer January February March
Bert 5 6 7
Charley 0 5 6
Ed 3 4 0
Pete 0 0 3


How can I manipulate the result of the second Query that it's matching
the Result of the First Query? And how can I insert a 0 for each time
the 2nd query didn't find a result for the given name mentioned in the
first query?

thanks for the help and feedback

Paul
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com