Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    Regular Coder
    Join Date
    Nov 2010
    Posts
    204
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Ignoring the output of date('F Y'); ?

    Wasn't quite sure what to do for a title on this one, anyway...

    number_format(getNetDonations(date('%')) + 23.97, 2)

    I'm using the above to try and pull total donations ever received on my site but here's where it gets hinky. There's safety checks in the code "or so I'm told by the author" to prevent wild cards from being used. Well, the dates in the row it's trying to pull from are in a format of date('F Y').

    ex. November 2010 , September 2009 etc. etc. etc.

    Well, I can't seem to pull anything but current month totals by either using

    number_format(getNetDonations(date('F Y')) + 23.97, 2)

    or

    number_format(getNetDonations('November 2010') + 23.97, 2)

    So I decided to try and go with something like below...

    $date = whatever ;

    number_format(getNetDonations($date) + 23.97, 2)

    But I don't know what to use for the whatever... so, here's my question...

    Regardless of how it is done I basically need to ignore the values in the row where the dates are stored in the named format (November 2010 etc.). So, anyone got any ideas on this. The code author has given one suggestion which I will quote below but I wouldn't know how to write said loop.

    It's probably not going to work with a wildcard without taking out the safety checks in the getNetDonations function, but the wildcard is % instead of * in SQL. You might need to write a loop to call the getNet. for each month from the start date until the current month.
    Edit: I'm guessing he meant something like writing a loop that uses the below with a set start date but no real end date.

    getNetDonations(date('F Y'))

    And then taking all of the figures gathered and making one big total which as of right now should be like $61.90
    Last edited by MoreBloodWine; 11-16-2010 at 03:27 AM.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,133
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    I have no idea what ANY of the above means.

    the dates in the row it's trying to pull from are in a format of date('F Y').
    Not that I can see in either of those tables.

    I say again: This DB design *SUCKS*.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Regular Coder
    Join Date
    Nov 2010
    Posts
    204
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    I have no idea what ANY of the above means.



    Not that I can see in either of those tables.

    I say again: This DB design *SUCKS*.
    In the item_number row the dates are formatted in F Y (November 2010)

    Also, it may suck but it works... it's just modifying stuff to get the desired look is whats being a PIA.

    That's what the function looks at when pulling data is the item number, in it's current format all I can get are current month net totals which is why the so called author suggested a loop or some crap.

    So this way instead of the function looking for a current month it grabs whatever it can regardless of wether or not the item number is January 2009 or March 2010 or even February 2020

  • #4
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Quote Originally Posted by MoreBloodWine View Post
    Also, it may suck but it works... it's just modifying stuff to get the desired look is whats being a PIA.
    It's trying to make a silk purse out of a Sow's ear which is your main problem, not the modifications per se.

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,133
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    So getNetDonations is PHP code? If you won't share the code, we can't help you.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,133
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    Quote Originally Posted by MattF View Post
    It's trying to make a silk purse out of a Sow's ear which is your main problem, not the modifications per se.
    I think it's more like a sow's posterior. Even an ear would be easier than this horrible DB design.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    Regular Coder
    Join Date
    Nov 2010
    Posts
    204
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    So getNetDonations is PHP code? If you won't share the code, we can't help you.
    Only so much I can share but at this point I could really care less about the authors so called rules. From what little he said, if a loop or some **** could be written for the dates or whatever to grab info for any item number in the F Y format it should work.

  • #8
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Quote Originally Posted by Old Pedant View Post
    I think it's more like a sow's posterior. Even an ear would be easier than this horrible DB design.
    You're spot on regarding that DB design and the code in general. It's just nasty from start to finish. It'd probably be a damned sight less work in the long run to just rewrite it from scratch in a sane fashion rather than modifying the existing stuff, judging by the snippets we've seen so far. I don't envy the O.P working with that stuff.

  • #9
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Quote Originally Posted by MoreBloodWine View Post
    Only so much I can share but at this point I could really care less about the authors so called rules. From what little he said, if a loop or some **** could be written for the dates or whatever to grab info for any item number in the F Y format it should work.
    What Old Pedant is trying to tell you is that what you've posted makes no sense whatsoever. Whichever muppet designed that code is probably about the only person on God's earth who actually understands it. It's literally nonsensical crap from our viewpoint. Without seeing all of the code for that function, there is no way to attempt deciphering it. Why do you think there have been no responses since you first posted the thread...

  • #10
    Regular Coder
    Join Date
    Nov 2010
    Posts
    204
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by MattF View Post
    What Old Pedant is trying to tell you is that what you've posted makes no sense whatsoever. Whichever muppet designed that code is probably about the only person on God's earth who actually understands it. It's literally nonsensical crap from our viewpoint. Without seeing all of the code for that function, there is no way to attempt deciphering it.
    Well, AFAIK... I posted everything related to that god forsaken function in my other post, I'll keep looking for other stuff just in case.

  • #11
    Regular Coder
    Join Date
    Nov 2010
    Posts
    204
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Net donation query solved, just used query from the function... I now get the output of $61.90 I was expecting when you add $23.97

    Code:
    	// Total Net Donations Received - Working
    	$request = mysql_query("select sum(b.mc_gross)-sum(a.mc_fee) from $db_table_sold_trans as a LEFT JOIN $db_table_sold_item as b ON a.id=b.parent_id LEFT join $db_table_sold_trans as c ON a.txn_id = c.parent_txn_id where a.payment_status = 'Completed' AND c.payment_status is NULL") or exit(mysql_error());
    	list($sum_donations) = mysql_fetch_row($request);
    	mysql_free_result($request);
    This post can be considered solved...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •