Jump to content

Jezza22

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Jezza22's Achievements

Member

Member (2/5)

0

Reputation

  1. Resolved see http://www.phpfreaks.com/forums/index.php/topic,269762.0.html
  2. Thanks for response "l4nc3r" Much Appreciated.. But I think I have got there now dude... Thanks, Jez
  3. Cracked it Guys!! Here is the Final Code, <?php /function SubTotal($data, $key, $centre) { $total = 0; foreach($data as $subarr) if (isset($subarr[$key])) if ($subarr[0]==$centre) $total += $subarr[$key]; return $total; } function displayArrayData($data) { $lastRowID = ''; //Iterrate through each record foreach ($data as $dataRow) { $subTotal=0; //Subtotal if this record is different ID than last if($dataRow[0]!=$lastRowID && $lastRowID != '') { echo "SubTotal : ".SubTotal($data, 3, $lastRowID); echo "<br />"; } //Set last ID value $lastRowID = $dataRow[0]; //Display current record echo "Centre ".$dataRow[0]." Centre Description ".$dataRow[1]." Amount ".$dataRow[3]; echo "<br />"; } //Close the table and final subtotal echo "SubTotal : ".SubTotal($data, 3, $lastRowID); } displayArrayData($data) This Display the following: -
  4. Is this not possible... Please someone comment.. :'(
  5. I am trying to get a subtotal of a key from associated array and really need help.. The array looks like the following:- Array ( [0] => Array ( [0] => 7000 [1] => CASH [2] => ALLOCATION [3] => 431.25 [4] => 22/08/2009 [5] => JS ) [2] => Array ( [0] => 7000 [1] => CASH [2] => CASH [3] => -1006.25 [4] => 22/08/2009 [5] => JS ) [3] => Array ( [0] => 7000 [1] => CASH [2] => ALLOCATION [3] => 1135.00 [4] => 24/08/2009 [5] => JS ) [4] => Array ( [0] => 7001 [1] => CARDS [2] => SL_Receipts [3] => -431.25 [4] => 23/08/2009 [5] => JS ) [5] => Array ( [0] => 7003 [1] => CHEQUES [2] => Chq 12458 [3] => -2000.00 [4] => 15/08/2009 [5] => JS ) [6] => Array ( [0] => 7003 [1] => CHEQUES [2] => Chq 122545 [3] => -5000.00 [4] => 24/08/2009 [5] => JS ) [7] => Array ( [0] => 7005 [1] => BANK [2] => BACS [3] => -1868.75 [4] => 20/07/2009 [5] => JS ) [8] => Array ( [0] => 7005 [1] => BANK [2] => BASC [3] => -2000.00 [4] => 21/07/2009 [5] => JS ) ) What I would like to do, is get the subtotal of Key 0 which is a Payment Centre, totalling Key 3 which is the Amount. I have written a function that subtotals the whole array, but I need a grouped subtotal.. Here's the code, <?php function SubTotal($data, $key) { $total = 0; foreach($data as $subarr) if (isset($subarr[$key])) $total += $subarr[$key]; return $total; } foreach ($data as $dataRow) { if($dataRow[0]!=$lastRowID && $lastRowID != '') { echo "Subtotal : ".SubTotal($data, 3); echo "<br />"; } echo "Centre ".$dataRow[0]." Centre Description ".$dataRow[1]." Amount ".$dataRow[3]; echo "<br />"; $lastRowID = $dataRow[0]; } ?> This produces the following: - The problem here is the subtotal is the whole amount, I need each centres subtotal.. Any Ideas would be much appreciated...??
  6. I have a function that creates an Array to be used in JavaScript. The data supplied to the function is a php Array. The function works well, but I am trying to get a subtotal of key 3 where Key 0 is the same.... The php array looks as follows Array ( [0] => Array ( [0] => 7001 [1] => CASH [2] => SL_Receipts [3] => -431.25 [4] => 23/08/2009 [5] => JS ) [1] => Array ( [0] => 7001 [1] => CASH [2] => SL_Receipts [3] => -431.25 [4] => 23/08/2009 [5] => JS ) [2] => Array ( [0] => 7001 [1] => CASH [2] => SL_Receipts [3] => -431.25 [4] => 23/08/2009 [5] => JS ) [3] => Array ( [0] => 7001 [1] => BANK [2] => CASH [3] => -431.25 [4] => 23/08/2009 [5] => JS ) [4] => Array ( [0] => 7001 [1] => CASH [2] => SL_Receipts [3] => -431.25 [4] => 23/08/2009 [5] => JS ) [5] => Array ( [0] => 7003 [1] => CHEQUES [2] => CHQ 12345 [3] => -5000.00 [4] => 23/08/2009 [5] => JS ) [6] => Array ( [0] => 7003 [1] => CHEQUES [2] => CHQ 123456 [3] => -2000.00 [4] => 23/08/2009 [5] => JS ) ) Here is my attempt that is not working because, It fails to total all of key 3 and only sub totals once.. Please Help !! while ($array = mysql_fetch_array($result, MYSQL_NUM)) {$data[] = $array; } //echo '<pre>' . print_r($data, true) . '</pre>'; sort($data); function displayArrayData($arrayValues) { echo "["; $lastRowID = ''; //Iterrate through each record foreach ($arrayValues as $dataRow) { //Show blank row if this record is different ID than last if($dataRow[0]!=$lastRowID && $lastRowID != '') { if ($_GET[breakDown]=="YES") { echo '[],'; echo '["","","Total",'.$dataRow[3].'],'; echo '[],'; } else { } } //Set last ID value $lastRowID = $dataRow[0]; //Display current record echo ' ['; for ($a = 0; $a <= 8; $a++) { echo ' "'.$dataRow[$a].'",'; } echo '],'; } //Close the table echo '];'; } This displays the following... [ [ "7001", "CASH", "SL_Receipts", "-431.25", "23/08/2009", "JS", "", "", "",], [ "7001", "CASH", "SL_Receipts", "-431.25", "23/08/2009", "JS", "", "", "",], [ "7001", "CASH", "SL_Receipts", "-431.25", "23/08/2009", "JS", "", "", "",], [ "7001", "CASH", "SL_Receipts", "-431.25", "23/08/2009", "JS", "", "", "",], [], ["","","Total",-5000.00], [], [ "7003", "CHEQUES", "Chq 12345", "-5000.00", "24/08/2009", "JS", "", "", "",], [ "7003", "CHEQUES", "Chq 123456", "-2000.00", "15/08/2009", "JS", "", "", "",], ];
  7. Ok I've found it!! http://us.php.net/get/pecl-5.2.6-Win32.zip/from/a/mirror This contains a version of php_printer.dll that loads the extension without any errors!! Hopefully someone else will find this usefull.. Jez
  8. I totally agree, but please point me in the direction of version more up to date.. I have search long and hard only finding this version.. And I think that it is no longer supported into PHP version 5, http://us3.php.net/manual/en/printer.installation.php and http://pecl.php.net/package/printer So it looks like that it can not be done with a windows platform and PHP 5.. Which surprises me..??
  9. Hi All, I am trying to get the php_printer.dll extension to work. I am running PHP 5.2.8 with Apache 2.2 on a windows XP platform. When I start Apache it fails to load the extension with the following error PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\Program Files\\PHP\\ext\\php_printer.dll' - The specified module could not be found.\r\n in Unknown on line 0 I have searched long and hard for a solution and have found lots of posts regarding this but nothing has worked so far. php.ini has "extension=php_printer.dll" and "extension_dir="C:\Program Files\PHP\ext" The file is located in the Extension folder and I downloaded the file from www.dlldll.com/php_printer.dll_download.html The file is 36Kb and dated 22.1.2004 Please help!! Thanks in advance, Jez
  10. Hi All, I have an extremely large error.log file and would like advice on why and what to do to stop it getting so large. Obviously something is seriously wrong or configured incorrect please advice.. Its currently at 10,112,840 Kb Jez..
  11. Bump on this please.... However, if my questions can not be answered, is it normal for the replication status, in Mysql Administrator, to be showing an entry with a status of Available?? because "my.ini" has no reference to Server-id and no options are selected on the Replication tab in Mysql Admin..?? which I would take to mean that Replication should not be on?? I am fairly new, so please go easy with me.. Thanks in advance, Jez
  12. Hi, I believe that I have been hacked because MYSQL administrator Replication Status is showing a entry and I am seeing query's appearing in the Server Logs that I have not sent. I know that I am only to blame here because I have ploughed straight into writing my web application without taking any real notice of any security procedures. I running MYSQL 5.0.67 on windows platform and would like any advice on how to stop the replication and it might have happened. please help, This is some of the entries in the log that I have not sent 1 Query DELETE FROM mysql.db WHERE Select_priv='N' AND Insert_priv='N' AND Update_priv='N' AND Delete_priv='N' AND Create_priv='N' AND Drop_priv='N' AND Grant_priv='N' AND References_priv='N' AND Index_priv='N' AND Alter_priv='N' AND Create_tmp_table_priv='N' AND Lock_tables_priv='N' AND Create_view_priv='N' AND Show_view_priv='N' AND Create_routine_priv='N' AND Alter_routine_priv='N' AND Execute_priv='N' 1 Query FLUSH PRIVILEGES 1 Query SELECT Full_name, Description, Email, Contact_information, Icon FROM mysql.user_info WHERE cast(cast(User AS BINARY) AS CHAR CHARACTER SET utf8)=cast(cast('root' AS BINARY) AS CHAR CHARACTER SET utf8) 1 Query select cast(cast(host AS BINARY) AS CHAR CHARACTER SET utf8) as h, cast(cast(NULL AS BINARY) AS CHAR CHARACTER SET utf8) as o, _utf8'Select_priv' as pn, cast(cast(Select_priv AS BINARY) AS CHAR CHARACTER SET utf8) as pv from mysql.user WHERE cast(cast(User AS BINARY) AS CHAR CHARACTER SET utf8)=cast(cast('root' AS BINARY) AS CHAR CHARACTER SET utf8) 1 Query select cast(cast(host AS BINARY) AS CHAR CHARACTER SET utf8) as h, cast(cast(NULL AS BINARY) AS CHAR CHARACTER SET utf8) as o, _utf8'Insert_priv' as pn, cast(cast(Insert_priv AS BINARY) AS CHAR CHARACTER SET utf8) as pv from mysql.user WHERE cast(cast(User AS BINARY) AS CHAR CHARACTER SET utf8)=cast(cast('root' AS BINARY) AS CHAR CHARACTER SET utf8)
  13. Mjdamato, You are indeed correct and I have cracked it, using your method. I am sorry If I sounded pedantic on my reply, I am fairly new, and any help received is much appreciated. I have been fighting this particular problem for a couple of days now and both your and MadTechie's advice has helped solve it... So thanks once again.. to both of you! Here's the finall code, //Retrieves the data from the database and creates an Array while ($array = mysql_fetch_array($result, MYSQL_NUM)) { $data[] = $array; } //Displays the Array data into a 2D javascript array function displayArrayData($arrayValues) { //Start of the Array echo "["; $lastRowID = '"'; //Iterrate through each record foreach ($arrayValues as $dataRow) { //Show blank row if this record is different ID than last if($dataRow[2]!=$lastRowID && $lastRowID != '') { echo '[],'; } //Set last ID value $lastRowID = $dataRow[2]; //Display current record echo ' ['; echo ' "'.$dataRow[0].'",'; echo ' "'.$dataRow[1].'",'; echo ' "'.$dataRow[2].'",'; echo ' ],'; } //End of the Array echo '[],];'; } displayArrayData($data)
  14. Thanks, to both equally good replies. I have tried MadTechie answer but unfortunately it results in, SL 121 9 SL 121 9 SL 121 10 SL 121 11 SL 121 16 Mjdamato, reply works.... But it works outputting a grid in PHP, HTML. I need the Array to be structured in this fashion because the Array feeds my grid which is written in Javascript, Activewidgets. So... I am now trying variations of MadTechie's code and adapting Mjdamato code to try and find the answer. Thanks to both of your help... Jez!! Once I have cracked it, I shall updated the thread, However, Mjdamato, please feel free to update your example, but using the Array to process the output.. Thanks once again !!!!
×
×
  • 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.