
beanymanuk
Members-
Posts
107 -
Joined
-
Last visited
Everything posted by beanymanuk
-
Combining 2 tables and outputting top 5 results
beanymanuk replied to beanymanuk's topic in MySQL Help
Hi How can I show the total_amount for each of the Select queries as well as the name, email, SUM(total_amount) that it already displays. SELECT name, email, SUM(total_amount) as total FROM ( SELECT name, email, total_amount FROM cashsumtotals WHERE cause= '$causename' UNION ALL SELECT name, email, total_amount FROM cardsumtotals WHERE cause = '$cause_id_get' ) tmp GROUP BY email ORDER BY total DESC LIMIT 6 -
Combining 2 tables and outputting top 5 results
beanymanuk replied to beanymanuk's topic in MySQL Help
Found a solution in the end Is this the most efficient way of doing it though? SELECT email, SUM(sumAmount1) as total FROM ( SELECT email, SUM(total_amount) as sumAmount1 FROM cashsumtotals WHERE cause= '$causename' GROUP BY email UNION ALL SELECT email, SUM(total_amount) FROM cardsumtotals WHERE cause = '$cause_id_get' GROUP BY email ) tmp GROUP BY email -
Combining 2 tables and outputting top 5 results
beanymanuk replied to beanymanuk's topic in MySQL Help
I have 2 tables though? cashsumtotals AND cardsumtotals Eg if have in cardsumtotals email total_amount Dan@???.com 16.66 in cashsumtotals email total_amount Dan@???.com 10 lisa.evans@?????.com 10 result to be email total_amount Dan@???.com 26.66 lisa.evans@???.com 10 -
Hi I am trying to combine 2 tables and show the 5 highest results SELECT email, total_amount FROM cashsumtotals WHERE cause = '$causename' AND SELECT email, total_amount FROM cardsumtotals WHERE cause = '$cause_id_get' I need to get the total SUM of total_amount where email address is the same and ORDER results by total_amount DESC and display the top 5 results Any help would be muchly appreciated.
-
I might be blind can't see why this code isn't working
beanymanuk replied to beanymanuk's topic in PHP Coding Help
I have tried moving code about and tried just inserting into the database with $sumcashinsert = mysql_query ("INSERT INTO cashsumtotals (cause, email, total_amount, firstname) VALUES('$cause', '$email', '$total_amount', '$firstname')"); So I'm now thinking the problem must be somewhere else on the site and not with this code -
I might be blind can't see why this code isn't working I have this piece of code but its not inserting my results into the database. function mysponsors() { global $wpdb; $get_sponsors_card = $wpdb->get_results("SELECT cause, email, SUM(amout) as total_amount FROM cashdepo GROUP BY email, cause"); foreach ($get_sponsors_card as $get_sponsors_card){ echo $get_sponsors_card->cause; $cause = $get_sponsors_card->cause; echo "<br>"; echo $get_sponsors_card->email; echo "<br>"; $email = $get_sponsors_card->email; echo $get_sponsors_card->total_amount; $total_amount = $get_sponsors_card->total_amount; echo "<br>"; $get_sponsors_card2 = $wpdb->get_results("SELECT DISTINCT firstname FROM accountinfo WHERE email = '$email'"); foreach ($get_sponsors_card2 as $get_sponsors_card2){ echo $get_sponsors_card2->firstname; $firstname = $get_sponsors_card2->firstname; echo "<br><br>"; } // INSERT INTO TABLE $sumcashinsert = mysql_query ("INSERT INTO cashsumtotals (cause, email, total_amount, firstname) VALUES('$cause', '$email', '$total_amount', '$firstname')"); } }
-
Hi I am trying to find out the total value of dontations raised per email address but in order to find this information I have to do a few queries in order to find out the email address by using there ID and also need to see what percentage of each donation and which cause this donation went to. Find out donation amount SELECT wp_supporters_donations.SFMemberNumber, wp_supporters_donations.KickbackAmount FROM supporter_2_cause RIGHT JOIN wp_supporters_donations ON supporter_2_cause.supp_id=wp_supporters_donations.SFMemberNumber GROUP BY wp_supporters_donations.SFMemberNumber Find out percentage here function getdonationperc($supp_id, $causeid, $ProcessDate){ global $wpdb; $fu=0; $ProcessDate = substr($ProcessDate, 0, 6); //echo $ProcessDate; //echo $supp_id." "; //echo $causeid; $new = $wpdb->get_results("SELECT * FROM dp_log WHERE sid=$supp_id AND cid=$causeid AND date=$ProcessDate AND fp != 'yes' ORDER BY id LIMIT 0, 1"); foreach ($new as $new){ $fu = $new->perc; //echo $fu; } //echo " RESULT11 ".$fu; if($fu=="0" || $fu==NULL){ $newresult = $wpdb->get_results("SELECT * FROM supporter_2_cause WHERE supp_id=$supp_id AND caus_id=$causeid AND deleted!='1' AND fp!='yes' ORDER BY id LIMIT 0, 1"); foreach ($newresult as $newresult){ $fu = $newresult->donation; //echo "wtf"; } //echo $fu; if($newresult == NULL) { $fu="0"; } }else{ //$fu="0"; } //echo $supp_id." - ".$causeid." - ".$ProcessDate." - ".$fu."<br/>"; //echo " RESULT ".$fu; return $fu; } Find out email address attached to each donation SELECT email FROM supporters WHERE id='SFMemberNumber' Then I need to add all donations up for each email address per each cause and output these / insert into a new table.
-
Thankyou for your help really appreciate it. I totally forgot about GROUP BY silly me. Your solution is totally is exactly what I needed.
-
Hi I am gathering numbers in an array and then want to add together all the numbers attached to the same email so I end up with the Grand totals of each email address. Below is the code I am using to pull out the email and attached values $getcashdonationsdb = $wpdb->get_results("SELECT * FROM cashdepo WHERE cause='$causename' AND status='2' ORDER BY user DESC"); $i = 0; while($i < $count2) { foreach($getcashdonationsdb as $getcashdonationsdb){ $dataa[$i]['email'] = $getcashdonationsdb->email; $dataa[$i]['cost'] = $getcashdonationsdb->cost; } } Anyone have any suggestions how I can achieve this most efficiently.
-
Hi I am using CKEditor (WYSIWYG) and I need to set a limit to the number of characters that can be entered and stop the user entering anymore when they have reached the limit. Anybody have any ideas on how this can be achieved? I have searched online but not had any luck.
-
WYSIWYG leaving <p which is messing output
beanymanuk replied to beanymanuk's topic in PHP Coding Help
I don't want to have to change it manually want it to automatically to prevent page layout looking wrong -
I have a WYSIWYG on my site and somehow the users input it in the database with this at the end <p The p tag is left open and messing up the styling on the page How can I fix it so this tag is removed or closed? Is there a php function I can use?
-
Combining 2 arrays and sorting them and outputting
beanymanuk replied to beanymanuk's topic in PHP Coding Help
I am trying to sort my results by date to show the latest 3 I have now combined all the results but I am not getting the latest 3 results outputted so I think I am sorting my array incorrectly. Any ideas how I sort by ['date'] so the latest 3 show? This is code I am using to sort uasort($data, "compareItems"); function compareItems($a, $b) { if ( $a->date < $b->date ) return -1; if ( $a->date > $b->date ) return 1; return 0; // equality } -
Hi everyone I have 2 queries which are pulling out results into arrays I think they are right I then insert a new column into each array one with [typeofdonation] as "cash" and one as "card" this is to be used later when outputting the results I then need to combine the 2 arrays into 1 array and then sort the combined array by date showing the latest ones first I then need to output the top 3 results The way the results are outputted is dependant on what [typeofdonation] is as they are outputting and styled differently Here is my code below I have got upto the combining the 2 arrays but am having difficulty doing this Once I have done this I then need to sort the results but I think my code I have tested on each array works ok and so will work once I have the combined array. Final part I am not sure on how to find and use what is in [typeofdonation] to determine the styling and way each of the 3 results is outputted Thankyou in advance for everyone who can hopefully help me in the right direction Peter <b>Card Donations</b><br><br> <?php $getcarddonations = $wpdb->get_results("SELECT wp_supporters_donations.SFMemberNumber, wp_supporters_donations.KickbackAmount, wp_supporters_donations.MerchantName, wp_supporters_donations.SpendDate from supporter_2_cause RIGHT JOIN wp_supporters_donations ON supporter_2_cause.supp_id=wp_supporters_donations.SFMemberNumber WHERE supporter_2_cause.caus_id = '54' ORDER BY wp_supporters_donations.SpendDate"); //UNION SELECT id, amout, cause, date FROM cashdepo WHERE cause='Lisas charity' AND status='2' ORDER BY id DESC foreach($getcarddonations as $getcarddonations){ $i = 0; while($i < 100) { $data[$i]['member'] = $getcarddonations->SFMemberNumber; $data[$i]['ammount'] = $getcarddonations->KickbackAmount; $data[$i]['merchant'] = $getcarddonations->MerchantName; $data[$i]['date'] = $getcarddonations->SpendDate; $data[$i]['typeofdonation'] = 'card'; $i++; } } function compareItems($a, $b) { if ( $a->date < $b->date ) return -1; if ( $a->date > $b->date ) return 1; return 0; // equality } uasort($data, "compareItems"); print_r( $data ); ?> <br><br><br><b>Cash Donations</b><br><br> <?php $getcashdonationsdb = $wpdb->get_results("SELECT * FROM cashdepo WHERE cause='Lisas charity' AND status='2' ORDER BY id DESC"); foreach($getcashdonationsdb as $getcashdonationsdb){ $i = 0; while($i < 11) { $dataa[$i]['member'] = $getcashdonationsdb->id; $dataa[$i]['ammount'] = $getcashdonationsdb->amout; $dataa[$i]['merchant'] = $getcashdonationsdb->cause; $dataa[$i]['date'] = $getcashdonationsdb->date; $dataa[$i]['typeofdonation'] = 'cash'; $i++; } } uasort($dataa, "compareItems"); print_r( $dataa ); ?> <br><br><br> <b>Combined</b><br><br> <?php $datar1 = ($data); $datar2 = ($dataa); $finalarray = array_combine($datar1, $datar2); //sort uasort($finalarray, "date"); //Print the output print_r($finalarray); ?>
-
Dropdown changing hidden field not working
beanymanuk replied to beanymanuk's topic in Javascript Help
Works in Chrome ok :s bizzare -
Dropdown changing hidden field not working
beanymanuk replied to beanymanuk's topic in Javascript Help
FF 5.0 it works then I reload the page and it doesn't and then will randomly start working again and the code I posted is all that's on the page -
I am testing this code I have found to change a hidden field but it works then i reload the page and it doesn't work I don't understand why Any ideas? Or another way of doing this that doesn't break Thankyou in advance <html> <body> <script type="text/javascript"> function changeHiddenInput (objDropDown) { var objHidden = document.getElementById("hiddenInput"); objHidden.value = objDropDown.value; } </script> <form> <select id="dropdown" name="dropdown" onchange="changeHiddenInput(this)"> <option value="1">One</option> <option value="2">Two</option> <option value="3">Three</option> </select> <input type="hidden" name="hiddenInput" id="hiddenInput" value="" /> </form> </body> </html>
-
Error bad I removed the " when copying into here and removing the value <input type="hidden" name="bn" value="????"> So thats not the cause
-
<form action="?????" method="post" name="paypal"> <input type="hidden" name="cmd" value="_donations"> <input type="hidden" name="business" value="????"> <input type="hidden" name="lc" value="US"> <input type="hidden" name="item_name" value="???"> <input type="hidden" name="country_code" value="GB" /> <input type="hidden" name="amount" value="?????" /> <input type="hidden" name="return" value="?????"> <input type="hidden" name="cancel_ return" value="????" /> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="no_note" value="0"> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="login_email" value="????" /> <input type="hidden" name="first_name" value="???" /> <input type="hidden" name="last_name" value="???" /> <input type="hidden" name="country_code" value="GB" /> <input type="hidden" name="address1" value="???" /> <input type="hidden" name="address2" value="???" /> <input type="hidden" name="city" value="???" /> <input type="hidden" name="email" value="???" /> <input type="hidden" name="H_PhoneNumber" value="???" /> <input type="hidden" name="bn" value=???"> <!---<input type="submit" value="Submit" />---> </form> <div class="info_header"></div> <div class="info_holder"> <h2><img src="???" alt="" class="info_icon"/> Please Wait - now entering the secure payment area</h2> <p><img src="???" alt="" /></p> </div> <div class="info_footer"></div> <script type="text/javascript"> document.paypal.submit(); </script>
-
I am trying to submit a form automatically using the below JavaScript it is working on one copy of site I have but not on another Form code here Then.... <script type="text/javascript"> document.paypal.submit(); </script> Any reason why this wouldn't be working?
-
Facebook Like Button checking if someone has liked certain page
beanymanuk replied to beanymanuk's topic in PHP Coding Help
my site doesn't have any login I want it linked into Facebook so if the user is signed into google on their computer they can click the like button on my site if they havn't already done so. Then after they have clicked like and this is recognized by Facebook I want to allow the user to proceed to another page. -
Button to send a tweet and checking the tweet was posted
beanymanuk replied to beanymanuk's topic in PHP Coding Help
I'm stuck on how I can detect that the user on my site definitely posted a certain worded tweet to his twitter account Once I know this is completed I can allow them to continue to another page -
Problem with that way is the searched words must tally up with the order of the SQL query In total there is about 14 fields in the database that I want to search by the users inputted search whatever it may be eg search of 'Ford Focus' or 'turbo focus' the search input could be anything (((UPPER(node_data_field_code.field_make_value)) LIKE ('%$filters%')) OR ((node_data_field_code.field_carmodel_value) LIKE ('%$filters%')) OR ((node_data_field_code.field_engine_value) LIKE ('%$filters%')) OR ((node_data_field_code.field_year_value) LIKE ('%$filters%')) OR ((node_data_field_code.field_key_value) LIKE ('%$filters%')) OR ((node_data_field_code.field_code_value) LIKE ('%$filters%')) OR .....