Jump to content

giraffemedia

Members
  • Posts

    180
  • Joined

  • Last visited

    Never

Everything posted by giraffemedia

  1. I've tried using GROUP BY in my query but it's only returning 1 result for each customer, not multiples. here is my test query... $forms_query = ("SELECT * FROM issues_booked AS i JOIN booking_form AS b ON i.ib_booking_form_number = b.bf_id JOIN contacts AS c ON c.contacts_id = b.bf_company_id WHERE i.ib_issue_number IN ($issues) AND c.client_lead = 'C' GROUP BY b.bf_id ORDER BY i.ib_issue_number ASC") or die(0); $forms_result = mysql_query ($forms_query); if (!$forms_result) { echo ("Problem because: " . mysql_error()); } while ($forms_row = mysql_fetch_array($forms_result)) { $test[] = $forms_row['ib_booking_form_number'] . ' - ' . $forms_row['ib_issue_number'] . ' - ' . $forms_row['companyname'] . ' - £' . $forms_row['bf_issue_cost']; $testing[] = number_format($forms_row['bf_issue_cost'], 2, '.', ''); } echo implode('<br /> ', $test); echo '<br /><br />' . '£' . array_sum($testing); Does the order of joining the tables in mysql affect this?
  2. Hi i'm not sure about the best way to go about counting total prices for each customer that i've returned from query. I've used array_sum to calculate the total amount from ALL results returned, but within the results are multiple rows for the same customers - they are separate orders. I would like to get a total of all orders for each customer, but i'm having trouble trying to group all results by a certain id or company name. Here is the result I am getting at the moment. The first column is the booking form number, the next is the issue the customer is booked into, the third is the company name and finally the price for that booking. 1284 - 61 - Test - £528.75 1264 - 61 - Testing - £575.75 1264 - 62 - Testing - £575.75 1284 - 62 - Test - £528.75 1262 - 62 - Testing - £264.38 1262 - 63 - Testing - £264.38 1264 - 63 - Testing - £575.75 1284 - 63 - Test - £528.75 £3842.26 I would like it to read something like 1284 - Test - £1586.25 1264 - Testing - £1727.25 1262 - Testing - £528.76 £3842.26 Anyone have any ideas? Thanks James
  3. Brilliant. That's just the ticket GuiltyGear. Thanks James
  4. Hello, i'm trying to round a number up from one decimal point to two but i'm not having any success. the number is 27.5 and i'd like to round it up to 27.50. Can I use the round function like so... $agency_discount = round((($bf_ad_rate/100) * $bf_agency_discount) ,2); echo $agency_discount; Regards James
  5. but I can't use array_product. That's why i'm looking at a different way akitchin.
  6. Excuse my ignorance but how do I do that obsidian? I've not really used functions before. James
  7. The function doesn't output anything ProjectFear. What do I have to do with it?
  8. I get the following error... Fatal error: Cannot redeclare array_product() (previously declared in /Applications/MAMP/htdocs/database/database_files/tools/page_space_sold.php:118) in /Applications/MAMP/htdocs/database/database_files/tools/page_space_sold.php on line 118 I haven't declared it before then so why is this happening?
  9. Does anyone know of an alternative function to array_product? I've uploaded my site to a live server and it's only running php 4.4.8 and not 5 that array_product needs. James
  10. No Matt, I would like to calculate just fractions but using the same principle. James
  11. He he - one more. What about if I was using fractions like 1/2, 2/3 etc. I've tried /\d+(?:\(/)\d+)?/ but it doesn't work. Anyone have an idea? James
  12. Thanks effigy. I also found http://www.phpvideotutorials.com/regex/ which looks very good and more up my street than reading the php site. I find most of the php site information a bit above me and too complex at the moment but i'm sure i'll get there! Regards James
  13. Brilliant!! ;D Thanks very much. Does anyone know anywhere that I can read more on pattern matching that is simple to understand for my brain!! James
  14. Just a quick question effigy, how can I change this to not strip out the decimal separator so I can use numbers such as 4.2 and 34.5? Regards James
  15. What would be the best way to replace multiple numbers from various rows returned from a mysql query? Say I get the following results... 2 columns, 1 column, 3 columns, 2 columns, 3 columns, 1 columns...etc etc How can I replace 1 with 4.2, 2 with 8.4, 3 with 12.6? Something like the following but obviously I couldn't use three in a row like so... str_replace("1 column", "4.2", $maths); str_replace("2 columns", "8.4", $maths); str_replace("3 columns", "12.6", $maths); Anyone have any ideas? thanks James
  16. Never mind - i've just sorted it. I've used the following... while ($row = mysql_fetch_array($classified_result, MYSQL_ASSOC)) { $maths = $row['bf_advert_size']; preg_match_all('/\d+/', $maths, $matches); $product[] = array_product($matches[0]) . '<br />'; } echo array_sum($product); He he you just beat me to it effigy! Thanks for your help. James
  17. Blimey, thanks effigy. How would I incorporate that into a while loop to perform the code on however many rows are returned then add the total? Something like... while ($row = mysql_fetch_array($classified_result, MYSQL_ASSOC)) { $maths = $row['bf_advert_size']; preg_match_all('/\d+/', $maths, $matches); echo $product = array_product($matches[0]) . '<br />'; } How can I add up each total returned?
  18. Hi I want to strip a string of all its letters and just leave the numbers. It contains a pair of comma separated values. Then I would like to multiply one number by the other. So the following... 16cm, 2 columns ...would be stripped to... 16,2 ...then multiply the remainder... 16 x 2 = 32 ...so that... $num = 32 How can I achieve this? I'm not sure if there is an expression that would do something like this. Regards James
  19. Yes secoxxx. I want it to go 61 65 70 62 66 71 63 67 72 64 68 73 65 69 74 etc etc...
  20. I've got a bit of a problem echoing the results from a function that tabulates data from an array. I have one set up that populates a 2 column table and would like to change this to a 3 column layout using the function posted on the Rawstar 7 site http://www.rawstar7.co.uk/site/pro/php/general/tut_halves.html Here is the function. The $issues array comes from a mysql query and works fine if I implode it then echo it, but it's not working with the function. Can anyone help please? James while($row=mysql_fetch_array($issues_result)) { $issues[] = '<input name="issue_number[]" type="checkbox" value="' .$row['issue_number']. '" tabindex="11" />Issue <strong>' .$row['issue_number'] . '</strong> ' . $row['issue_month'] . ' ' . $row['issue_year'] ; } $data = $issues; function table_04($data, $cols, $details="") { $sret = "<table ".$details.">\n"; $all = count($data); $offset = ceil($all/$cols); for($i=0; $i < $offset; $i++) { $sret .= "<tr>"; for($j=0; $j < $cols; $j++) { $sret .= "<td>".$data[($i+($j*$offset))]."</td>"; } $sret .= "</tr>\n"; } $sret .= "</table>\n"; return $sret; } print table_04($data, "border='1' width='100px'");
  21. That makes sense to me. I think i'll rewrite the pages as one and see where I go from there. Thanks for all your help guys. James
  22. If that's the case would it be better to echo the entire form in an isset statement so that all the data get's sent as it would normally without php?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.