Can you please tell me if I'm doing this part wrong. This seems to be the problem area, so I'll only show this aspect of the code, as it's a pretty long system I'm building.

First let me say this, I've been working on this since about 6am this morning, almost non stop, so I'm very tired, and may not get my point across like I normally would when I'm well rested(not much lately;o))

Second, let me explain what I'm doing. I am writing my own Affiliate program into our Website. I'm using ONE perl script, for the entire system, every aspect of our site. Kind of like this site does, but just a different style of programming. This affiliate program is going to have a way of tracking how the affiliates are doing with each different banner we have created for them.

When they click on "view stats", it loads a page with Daily Stats the default, and gives them a menu of several other choices. The Daily, shows every banner, and under the banner it shows impressions, clicks, sales and a Click Through Rate(clicks divided by impressions).

That is what I'm trying to do...
Here it is:
$sth = $dbh->prepare (qq{ SELECT * FROM table_name ORDER BY bid }) +; $sth->execute(); while ($row = $sth->fetchrow_hashref()) { $tracked_impressions = 0; $tracked_clicks = 0; $tracked_sales = 0; $sth1 = $dbh->prepare (qq{ SELECT * FROM aff_trac WHERE id = $ +aff_id AND bid = $row->{bid} AND t BETWEEN "$database_query_date_s" A +ND "$database_query_date_e" }); $sth1->execute(); while ($aff_row = $sth1->fetchrow_hashref()) { if ($aff_row->{utype} =~ /^i$/) { $tracked_impressions++; } elsif ($aff_row->{utype} =~ /^h$/) { $tracked_clicks++; } elsif($aff_row->{utype} =~ /^s$/) { $tracked_sales++; } } $html_content .= qq~ <tr valign="top"> <td align="center" class="header_cell"> Advertisement ID: $row->{bid} </td /> </tr /> <tr valign="middle"> <td align="center" class="non_label_cell"> <img src="$surl?pg=$in{pg}&do=$in{do}&action=show_imag +e&imgid=$row->{bid}" border="0" alt="Program ID $row->{bid}" /> </td /> </tr /> <tr valign="top"> <td align="left" class="non_label_cell"> <table class="non_label_cell" align="center" border="1 +" cellpadding="2" cellspacing="2" bordercolor="$Page_table_border_col +or" width="100%"> <tr valign="top"> <td align="left" class="label_cell"> <b>Impressions</b>: </td /> <td align="left" class="non_label_cell"> <b>$tracked_impressions</b> </td /> <td align="left" class="label_cell"> <b>Clicks</b>: </td /> <td align="left" class="non_label_cell"> <b>$tracked_clicks</b> </td /> <td align="left" class="label_cell"> <b>Click Through Rate</b>: </td /> <td align="left" class="non_label_cell"> <b>~; if ($tracked_click || $tracked_impressions) { $html_content .= ($tracked_click*1) / ($tracked_impressions*1) +; } else { $html_content .= "1000"; # Temp so I can see when it did NOT w +ork... or there was 0 to track... } $html_content .= qq~%</b> </td /> <td align="left" class="label_cell"> <b>Sales</b>: </td /> <td align="left" class="non_label_cell"> <b>$tracked_sales</b>: </td /> </tr /> </table /> </td /> </tr />\n~; } $dbh->disconnect();
Anyways that is the part that does not seem to be working. It actually works ok, but it's only showing 1 click and 1 impression when I've made sure there are at least 2 or 3 of each. Plus it either shows 1000%(did not work) or 0%.

Do you see something WRONG with that code?

thx,
Richard

In reply to Troubleshooting help... by powerhouse

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.