How to display empty months when grouping records by month

Guys, I've got a recordset that successfully displays all
records in the
table grouped according to the month that the record was
created in.
This allows me to display a Monthly tally (a bit like a
barchart - where the
height of the column is derived by the qty of records for
that given month)
for each of the months in the year so far. However, it dawned
on me today
that if there was no activity in a given month, the month
simply doesn't
appear at all, rather than displaying but showing "0" as I
would prefer.
For example, the type of thing I want to display onscreen is:
Month 1 2 3 4 5 6 7 8 9 10 11 12
But let's say there were no records inserted in months June
to September
(inclusive), what I'm actually getting onscreen is:
Month 1 2 3 4 5 10 11 12
But what I actually want to appear onscreen is:
Month 1 2 3 4 5 6 7 8 9 10 11 12
I hope that makes some kind of sense...
I'm using Dreamweaver CS3, ASP/VBScript, and MySQL.
My current SQL Statement is as follows:
SELECT Count(AffiliateID) AS TotalClicks, MONTH(`VisitDate`)
AS Month
FROM tbl_affiliaterefferals
WHERE `AffiliateID` = "49" AND YEAR(`VisitDate`) =
YEAR(Now()) GROUP BY
MONTH(`VisitDate`)
ORDER BY MONTH(`VisitDate`) ASC
I figured one workaround would be to have 12 separate
recordsets - one for
each month - on the one page, but there must be a cleaner way
of doing it
surely?
Any/all help greatly appreciated.
Regards
David

This is a multi-part message in MIME format.
------=_NextPart_000_0086_01C932EC.D9CE33D0
Content-Type: text/plain;
format=flowed;
charset="iso-8859-1";
reply-type=original
Content-Transfer-Encoding: 7bit
Hi Joe,
I've simply got a table, within one cell of which is another
table to which
I've applied a background colour and am specifying the height
of the <td>
cell as the qty of the number of records returned for Month 1
of the current
year. Then I'm applying a repeat region to the <TD>
cell containing the
table that varies in height, in order to force the table to
repeat
horizontally according to the number of records (months)
retrieved from the
database.
The code for the table is in the attached txt file.
I appreciate your time in responding however you must have
missed my
comments about what I'm working in as I'm working in
ASP/VBScript and
haven't the first clue when it comes to PHP.
I don't suppose you know or can point me in the direction of
an ASP
equivalent of your suggestion?
Regards
David
"Joe Makowiec" <[email protected]> wrote in
message
news:[email protected]...
> On 20 Oct 2008 in macromedia.dreamweaver, DTB-K wrote:
>
>> I figured one workaround would be to have 12
separate recordsets -
>> one for each month - on the one page, but there must
be a cleaner
>> way of doing it surely?
>
> Without seeing the code you're using to display it...
>
> Probably what that code is doing is looping through the
recordset:
>
> <?php do { ?>
> ...
> <?php } while ($row_dates =
mysql_fetch_assoc($dates)); ?>
>
> That's DW's standard PHP MySQL recordset behavior. What
you want to do
> is something more like:
>
> <?php
> for ($i=1;$i<13;$i++) { // Do 12 months
> echo '<p>Month: ';
> echo $i; //Echo the month
> if ($row_Recordset1['Month'] == $i) {
> // Have data for this month
> echo ' Clicks: ';
> echo $row_Recordset1['TotalClicks'];
> // Now get the next row
> // Note that we only want to get the next row if the
current month
> // has data. That's why the fetch command is inside the
if.
> $row_Recordset1= mysql_fetch_assoc($Recordset1);
> } // End if
> echo "</p>\n";
> } // End for
> ?>
>
> --
> Joe Makowiec
>
http://makowiec.net/
> Email:
http://makowiec.net/contact.php
------=_NextPart_000_0086_01C932EC.D9CE33D0
Content-Type: text/plain;
format=flowed;
name="Code.txt";
reply-type=original
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="Code.txt"
<table border=3D"0" cellpadding=3D"0"
cellspacing=3D"0">
<tr>
<td colspan=3D"2" valign=3D"bottom"><h1>Current
Year:</h1></td>
</tr>
<tr>
<td valign=3D"bottom" =
class=3D"BodyTxtsml"><strong>Month</strong></td>
<%=20
While ((Repeat1__numRows <> 0) AND (NOT
Rs_MonthlyClicks.EOF))=20
%>
<%Dim TotalClicks, Cellheight
TotalClicks =3D =
FormatNumber((Rs_MonthlyClicks.Fields.Item("TotalClicks").Value),
0, -2, =
-2, -2)
Cellheight =3D (TotalClicks)
%> =20
<td valign=3D"bottom" class=3D"BodyTxtsml" =
title=3D"<%=3D(TotalClicks)%>"><div
align=3D"center"><table border=3D"0" =
cellspacing=3D"0" cellpadding=3D"0">
<tr>
<td height=3D"<%=3D(Cellheight)%>" =
bgcolor=3D"#003366" onMouseOver=3D"this.bgColor =3D
'#FFDB9D'" =
onMouseOut=3D"this.bgColor =3D'#003366'"
width=3D"40"> </td>
</tr>
=
</table><%=3D(Rs_MonthlyClicks.Fields.Item("Month").Value)%></div></td>
<%=20
Repeat1__index=3DRepeat1__index+1
Repeat1__numRows=3DRepeat1__numRows-1
Rs_MonthlyClicks.MoveNext()
Wend
%> =20
</tr>
</table>
------=_NextPart_000_0086_01C932EC.D9CE33D0--

Similar Messages

  • How to display 3 month columns and YTD column

    Hello,
    I need a help. My report layout requires to display the data in 3 dynamic month columns and one Fiscal year Year-to-date column for a period of time. For example, ending month is FEB:
    Items : DEC : JAN : FEB : FY YTD
    A     : $10     : $11     : $12     : $100     
    B     : $1     : $2     : $3     : $10
    (Note: FY YTD is the total sum from OCT to FEB (5 months), not 3 months to be displayed)
    I tried to create a query and use Matrix with group, but the report always display five (5) month columns
    from OCT to FEB instead of displaying three (3) month columns. If the query is limited to display
    three months as desired, then the total sum will be 3 displayed months only (instead of 5 months).
    How to create a query or how to display three months and FY YTD or do anything else with Oracle Builder9i?
    Thanks,

    You could use the DECODE function and variables
    i.e. have a four column report
    in your query use somthing like
    , decode(period,:P_PERIOD1,1,0)* amount as period1
    , decode(period,:P_PERIOD2,1,0)* amount as period2
    , decode(period,:P_PERIOD3,1,0)* amount as period3
    , amount as ytd
    In your before report trigger poulate the variables with your required values

  • How to Display Two Months in Sharepoint Calendar

     
    1. I have SharePoint Server. Do I need other software to the make the following change in Calendar?
    2. How to hide Saturday and Sunday or move Sunday to the first day. (Sunday is the last day in my current calendar. )
    3. How to display two months on one page?
    Thanks.

    Hello,
    For those still looking, you should ask on the
    SharePoint forums.
    Karl
    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C40686F746D61696C2E636F6D'-split'(?&lt;=\G.{2})'|%{if($_){[char][int]&quot;0x$_&quot;}})

  • How to display list process, when i run sql*loader in c#

    Hello,
    How to display list process, when i run sql*loader in c#. I mean when i run sql*loader from cmd windows, i get list process how many row has been inserted. But when i run SQL*Loader from C#, i can't get process SQL*Loader.
    This is my code:
    string strCmd, strSQLLoader;
    string strLoaderFile = "XLLOAD.CTL";
    string strLogFile = "XLLOAD_LOG.LOG";
    string strCSVPath = @"E:\APT\WorkingFolder\WorkingFolder\sqlloader\sqlloader\bin\Debug\8testskrip_HTTP.csv";
    string options = "OPTIONS (SKIP=1, DIRECT=TRUE, ROWS=1000000,BINDSIZE=512000)";
    string append = "APPEND INTO TABLE XL_XDR FIELDS TERMINATED BY ','";
    string table = "OPTIONALLY ENCLOSED BY '\"' TRAILING NULLCOLS (xdr_id,xdr_type,session_start_time,session_end_time,session_last_update_time,session_flag,version,connection_row_count,error_code,method,host_len,host,url_len,url,connection_start_time,connection_last_update_time,connection_flag,connection_id,total_event_count,tunnel_pair_id,responsiveness_type,client_port,payload_type,virtual_type,vid_client,vid_server,client_addr,server_addr,client_tunnel_addr,server_tunnel_addr,error_code_2,ipid,c2s_pkts,c2s_octets,s2c_pkts,s2c_octets,num_succ_trans,connect_time,total_resp,timeouts,retries,rai,tcp_syns,tcp_syn_acks,tcp_syn_resets,tcp_syn_fins,event_type,flags,time_stamp,event_id,event_code)";
    strCmd = "sqlldr xl/secreat@o11g control=" + strLoaderFile + " LOG=" + strLogFile;
    System.IO.DirectoryInfo di;
    try
    System.Diagnostics.ProcessStartInfo cmdProcessInfo = new System.Diagnostics.ProcessStartInfo("cmd.exe");
    di = new DirectoryInfo(strCSVPath);
    strSQLLoader = "";
    strSQLLoader += "LOAD DATA INFILE '" + strCSVPath.ToString().Trim() + "' " + append + " " + table;
    StreamWriter writer = new StreamWriter(strLoaderFile);
    writer.WriteLine(strSQLLoader);
    writer.Flush();
    writer.Close();
    // Redirect both streams so we can write/read them.
    cmdProcessInfo.RedirectStandardInput = true;
    cmdProcessInfo.RedirectStandardOutput = true;
    cmdProcessInfo.UseShellExecute = false;
    cmdProcessInfo.LoadUserProfile = true;
    //System.Diagnostics.Process.Start("CMD.exe", strCmdLine);
    // Start the procses.
    System.Diagnostics.Process pro = System.Diagnostics.Process.Start(cmdProcessInfo);
    // Issue the dir command.
    pro.StandardInput.WriteLine(strCmd);
    // Exit the application.
    pro.StandardInput.WriteLine("exit");
    //Process[] processlist = Process.GetProcesses();
    //foreach(Process pro in processlist){
    Console.WriteLine("Process: {0} ID: {1}", pro.ProcessName, pro.Id);
    Console.WriteLine(pro.StandardOutput.ReadLine());
    // Read all the output generated from it.
    string strOutput;
    strOutput = pro.StandardOutput.ReadToEnd();
    pro.Dispose();
    catch (Exception ex)
    return;
    finally
    Thanks.

    friend
    sqlldr is an application residing in the OS. procedure runs in the dbms engine.
    you cannot run an os command directly from a procedure or a function or a package .
    If you want to do so you need to use either a daemon process created by a PRO*C program
    or a JAVA stored procedure to do so.
    just refer to previous question forums, you can find the solution. Somebody has already given a solution using
    java to run an OS command . check it out
    prakash
    [email protected]

  • Why does safari display empty page when localhost service are requested using https?

    Why does safari display empty page when localhost service are requested using https and port 37542 (https://localhost:37542/), but displays page properly when regular port is used (https://localhost/).
    Both links return the same json response and work properly in other browsers. Certificate for localhost service was installed to the storage.

    Problem solved.
    I added headers for localhost service response and page displayed normally.

  • How to display success message when data is changed in the custom tab in MM

    Hi,
    I have added a new custom data tab in the MM01/MM02/MM03 transactions. Whenever I do changes to fields in the custom tab in MM02 transaction, and no changes in the standard tabs, I will get a message stating "No Changes Made".
    But if I do changes in the standard tabs, it works as usual with display of message "Changes to particular material has been done.
    Please let me know, if anyone of you know, how to display the success message if the changes to the custom tab is done.
    Thanks in advance,
    sudhanva

    Hi Sudhanva,
    The exit EXIT_SAPLMGMU_0001 is a function exit that you can use for custom validation but not to add custom tab/screen.
    But the message issued by SAP is not related to this Function Exit.
    If you have used a Screen Exit, then there must be some Function Exits also in the same Enhancement using which you can assign the value of custom fields to/from the standard structure. Thus when the value of any custom field is changed the system can understand that the some changes have been changed and will  not issue the message.
    In case you have used a BADI, there can be other methods in the BADi using whcih you can assign the value of custom fields to/from the standard structure. This might also prevent the message from being displayed.
    I could try giving you further details if you can provide the name of the Enhancement/BADi that you used to add the additional tab.
    Hope this helps.
    Regards,
    Abhisek.

  • How to display three months data in ALV grid control

    Hi
    Thanks for all.I have tried now it is working but as per requirement month name and cumulative total will display like this format.cumulative total means month1amount+ month2amount+month3amount.And one more thing month range will change some times means sometimes i will give January date to march date and sometimes i will give July date to October date. but date range is same means between dates range is three months.
    please tell me how to display.
    GAS PRESSURE WELDING COST EFFECTIVENESS                                        Dec-11                         Cummulativetotal
    Sr. No             Item             Unit           Rate          Qty           Amount             
    GAS PRESSURE WELDING COST EFFECTIVENESS                                      Jan-12
    Sr. No             Item             Unit           Rate          Qty           Amount             
    GAS PRESSURE WELDING COST EFFECTIVENESS                                     Feb-12
    Sr. No             Item             Unit           Rate          Qty           Amount             
    Thanks & Regards,
    Vasu.
    Moderator message: only one thread per issue, please.
    Edited by: Thomas Zloch on Feb 20, 2012

    Hi
    Thanks for all.I have tried now it is working but as per requirement month name and cumulative total will display like this format.cumulative total means month1amount+ month2amount+month3amount.And one more thing month range will change some times means sometimes i will give January date to march date and sometimes i will give July date to October date. but date range is same means between dates range is three months.
    please tell me how to display.
    GAS PRESSURE WELDING COST EFFECTIVENESS                                        Dec-11                         Cummulativetotal
    Sr. No             Item             Unit           Rate          Qty           Amount             
    GAS PRESSURE WELDING COST EFFECTIVENESS                                      Jan-12
    Sr. No             Item             Unit           Rate          Qty           Amount             
    GAS PRESSURE WELDING COST EFFECTIVENESS                                     Feb-12
    Sr. No             Item             Unit           Rate          Qty           Amount             
    Thanks & Regards,
    Vasu.
    Moderator message: only one thread per issue, please.
    Edited by: Thomas Zloch on Feb 20, 2012

  • IBots - How to send an alert when NO records are returned

    It seems straightforward enough to send an alert when a query produces results, but I want to do the opposite. For instance, I only want to get an email at 7am when an object has no data in it for the current day. I do not want to know every day that records are returned.
    how would i set up such an iBot such that it fires every day, and only emails me when no records are returned form the query?

    1) Create a small report called "No Records" and create an unscheduled iBot for this report.
    2) You have your iBot created for the original report, yes? Okay. If you don't want any notification when records are produced for this iBot, then in the Destinations tab, make sure all the boxes are unchecked for "Specific Devices."
    3) Now in the Advanced tab, click on the "Add Action" button under the "Execute these actions when no records are returned by the conditional request" section.
    4) Click on "iBot."
    5) Navigate to the "No Records" ibot created in step one.
    Now, when the original ibot fires and there are records, nothing will be sent because you unchecked all ways to get notification. But when there are no records, this event will fire the chained ibot you linked to in the Advanced tab. This iBot will have as an attachment, your report that says "No Records."

  • How to display a popup when closing a sales order form

    Hi Team,
    I need to display a popup when a user tries to close a sales order. Can anyone please let me know if we can do it through personalization or custom.pll.
    Thanks,
    Vikash S.

    When we close order form with out saving , a pop up shows to save or not, try to check that how closing event is being captured.

  • How To Display Message Dialog when the Database is Empty

    Hello everybody...Im writing a mini app which uses swing GUI and JDBC. the program is a mini contacts book which adds data to the database thru the textfields and retrives the data to the textfield.now what i want to do is when the menu "show record" is clicked and then there is no data in the database, it should display "no records found" because the database is empty. how do i do that?I need urgent help thanks...

    Scrolling of results can be done in 2 ways.
    if ur result set are small, read them in one go and display as PREV / NEXT button is pressed,
    Or if ur result set is very large, maintain internal counters, and navigate with them.
    When u are at first / last entry, better dissable those button actions.
    I hope this will help you.
    Regards
    BS

  • How to call a method when navigating records?

    Jdev 11.1.1.2.0
    I have an app displaying records one at a time in a panelFormLayout.
    I have a selectManyShuttle object linked to the form with a PartialTrigger.
    The shuttle is being populated using the methods from the SRDemo app and are functioning correctly when adding/removing records including the correct parent id through the partialtrigger.
    But, the shuttle is not refreshing as the parent record is changed. I have to manually refresh it.
    How can I attach a method call #{backing_MessageTrainingCenters.refreshSelectedList} to fire when the parent record navigates or is there a way to do this automatically?
    Same question with the commit button. I currently have a save button for the shuttle and a commit for the parent. I would like to call the method to save the shuttle records when the commit is pressed.

    What I've done to sort of get this to work
    In the backing bean (using the SRDemo stuff) I changed the refreshSelectedList to use an ActionEvent
    public void refreshSelectedList(ActionEvent event) {
    refreshSelectedList = true;
    I right-clicked one of the the built in nav buttons and told it to create method binding for action then took that method and made it take a string for the operation.
    public String navAction(String navigate) {
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding = bindings.getOperationBinding(navigate);
    Object result = operationBinding.execute();
    if (!operationBinding.getErrors().isEmpty()) {
    return null;
    return null;
    I made 4 buttons and set the ActionListener to #{backing_MessagePrograms.refreshSelectedList} on each one then did a create method binding for action.
    Inside each of these methods I made a call to navAction(String navigate) above passing in the operation I want.
    public String cb8_action() {
    cb2_action("First");
    return null;
    This works ok for this single scenario but I have 2 multi select lists to refresh when navigating. So I'm still stuck with trying to tell the other component to refresh.
    I cannot find the "magic" that happens when I click the button with the listener ActionListener set that makes it refresh.
    How can I tell both multiselect components to refresh from one of my methods?
    or
    *How can I set a button to use 2 ActionListeners like #{backing_MessagePrograms.refreshSelectedList} & #{backing_MessageTCs.refreshSelectedList}?*

  • How to display UTF - 8 when genereate excel from java

    I use Jsp to input chinese words as UTF-8, and store them to Oracle. When I display these words in Jsp, there is nothing wrong. But if I generate Excel through servlet, these words display as "???e????", how can I resolve this problem?
    Thank you!!!

    What library are you using to generate xls files? Then find that library's support fora.

  • How to display table name in the Record history

    Hi,
    I have developed a new custom form. When I click on the record history, it displays details like updated_by , update_Date.
    But it doesnt show the table name ( of the data block ). Is there any coding to be done to display the table name ?
    Regards,
    Suresh

    Sounds like some custom form for the eBusines-suite. Maybe you get an answer in an eBusiness-suite related forum, maybe here OA Framework

  • How to display three months by prompt

    Hi,
    I have a requirement in dashboard,
    there is a prompt of month, if I select one month, there will show three months' data,
    example, if I select '201108', it will display 201107,201108,201109,
    If I use '+' or '-' in month calculation, it has a problem, like across two year, 201012,201101,201102.
    So how can I realize this requirement?
    thank you!

    example, if I select '201108', it will display 201107,201108,201109,
    If I use '+' or '-' in month calculation, it has a problem, like across two year, 201012,201101,201102.I know this is not straight forward but you need to think this in more logical way. I know you have acheived it till the point you are selecting either Jan or Dec month like 201112 OR 201101.
    EG: SUPPOSE I HAVE SELECTED 201112
    Here you need to create a MID report with 3 cols like CURR MTH, PRV MTH, NEXT MTH
    In NEXT MTH apply logic like :
    - Convert 'CURR MTH + 1' to CHAR
    - EXTRACT 2 CHARS from RIGHT
    - IF EXTRACT = 13 THEN CONCAT (EXTRACT 4 CHARS FROM LEFT --- convert to INT and add 1. This will give you 2012 and concat this with 01). Again change to INT
    REPORT will give: 201112, 201201, 201111
    EG: SUPPOSE I HAVE SELECTED 201101
    In PRV MTH apply logic like :
    - Convert 'CURR MTH -1' to CHAR
    - EXTRACT 2 CHARS from RIGHT
    - IF EXTRACT = 00 THEN CONCAT (EXTRACT 4 CHARS FROM LEFT --- convert to INT and minus 1. This will give you 2010 and concat this with 12). Again change to INT
    REPORT will give: 201101, 201102, 201012
    You just need to play with String and CAST function to get it done
    Rest you know..Hope this helps

  • How to display different screens when starting the Webdynpro app?

    Hi All,
    When user starting up the Webdynpro app, it will first check some value in the persistent layer. If the check result is ok, it will show the normal app screen to the user; if the check failed, it will show the error screen.
    Now I write the check function in the view controller, But I think it is not a good approach, because there are some initialize code in the component controller, so before my check function reached, the server will waste some resource to execute the initialize code in the component controller.
    Would anyone give me some hints on how to move the check function to component controller and then display the different screen to the end-user?
    Thans and Best regards
    Deyang

    Deyang,
    I've opened <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/developerareas/webdynpro">Web Dynpro</a> section on SDN and see the featuring article:
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/developerareas/webdynpro?rid=/library/uuid/751d003a-0b01-0010-8996-afbaa3fd5339">cross-component Navigation, Explained</a>
    <i>New resources demonstrate <b>how to navigate to certain views from within Web Dynpro components</b>, and fill some gaps in the Sample Application and Tutorial matrix.</i>
    Should be exactly what are yuo looking for
    Valery Silaev
    EPAM Systems
    http://www.NetWeaverTeam.com

Maybe you are looking for

  • Superdrive There but Not Working at All

    My superdrive appears as normal in the system profiler. It will accept and eject disks. However, there is no sign of life in the drive. No temporary spinning or other sign of activity, just silence. I've tried a variety of CDs and DVDs. I tried updat

  • Problem in scenario JDBC - XI - File

    Hi, In my scenario, data is fetched from database and passed on to external file. In my design i have put source structure which is exactly the same as database structure and mapped it to target structure. Message interfaces for both the source and t

  • I am trying to host my own website/mail server

    I am pretty new with osx server and from all the info i found was to create a "intranet" per say.. I have AT&T uverse and I am hosting my own site..that part was pretty easy even tho i am not sure if i did set up the DNS server right... i set up the

  • Account Segmentation Document

    Any one can send me link for the Account Segmentation Document. Thanks & regard Manvendra

  • Lumia 900 update error 80070424

    I have just bought Nokia Lumia 900, and everything works and looks very well. But the phone won´t update its firmware (current version is the factory preset of 2175.2101.8779.12201). ZUNE update procedure keeps bombarding me with 80070424 error. Alre