Jump to content

Paulqvz

Members
  • Posts

    35
  • Joined

  • Last visited

Paulqvz's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi all. I call a stored proc from mysql and show it in php html. function CreateTableRow($RowItem){ $rowHtml = "<tr border: 1px solid black; border-collapse: collapse;>"; $array = get_object_vars($RowItem); foreach($array as $keyItem => $value){ $rowHtml .= "<td border: 1px solid black; border-collapse: collapse;>{$value}</td>"; } $rowHtml .= "</tr>"; return $rowHtml; } This works great, but i am now stumped on how to get it to when it finds a cell with 0 value to use previous value thats not 0. I tried fixing it in mysql with stored proc but it does not make all 0 with previous value. Here is my sql. SELECT GROUP_CONCAT( DISTINCT CONCAT( 'case when sum(if(t.ipDATE = ''',ipDATE,''', t.market_value_1, 0)) = 0 and SUM(IF(t.ipDATE = date_sub(''',ipDATE,''',interval 1 day), t.market_value_1, 0)) = 0 then round(SUM(IF(t.ipDATE = date_sub(''',ipDATE,''',interval 2 day), t.market_value_1, 0)),6) when sum(if(t.ipDATE = ''',ipDATE,''', t.market_value_1, 0)) = 0 then round(SUM(IF(t.ipDATE = date_sub(''',ipDATE,''',interval 1 day), t.market_value_1, 0)),6) else round(sum(if(t.ipDATE = ''',ipDATE,''', t.market_value_1, 0)),6) end AS `',CONCAT(ipDATE),'`' ) ORDER BY YEAR(ipDATE) ASC, MONTH(ipDATE) ASC,DAY(ipDATE) ASC ) INTO @sql But this does not work for when there a 6 dates in a row with 0 values
  2. wel i tried lots of different code - see my examples on top.
  3. no i do not have controll over the format - i must say i have posted here 3 times and not once was it helpfull. why is this forum still active as no one can help with a smal problem like this?
  4. how do i after i find the expression string stop after the last line with a tab?
  5. hi there the first thing i would do is search for the string. once i have found it i will count the amount of lines til the next entry without a tab spacing - knowing that would be my next header. then i would show these entries . Was that good?
  6. Hi all. I have a php file that i need to read contents from. I can search for a string but i am stumped on how to start from a point and to end at a point Below is the payout of the file. I just want to return Paul1 plist1: plist1 plist2: plist2 plist3: plist3 plist4: plist4 and not the rest. quote_lost_reason "": "" Price: Price Product: Product Other: Other Paul1 plist1: plist1 plist2: plist2 plist3: plist3 plist4: plist4 Site Lighting Interior: Interior Exterior: Exterior credit credit_note: Credit Note here is my code so far $file = '/var/www/html/***/custom/include/language/lang.en_us.lists.php'; $searchfor = "Paul1"; $array = file($file); //print_r($array); header('Content-Type: text/plain'); $contents = file_get_contents($file); $pattern = preg_quote($searchfor, '/'); $pattern = "/^.*$pattern.*\$/m"; if(preg_match_all($pattern, $contents, $matches)){ echo "Found matches:\n"; echo implode("\n", $matches[0]); } else{ echo "No matches found"; }
  7. Good day I have a label script where i have to print labels. the problem i have is that it is not returning the right amount of rows dependant on qty column. $sql="SELECT so.`name` AS so_name, sol.`name` AS sol_name,sol.`quantity` AS sol_quantity,`delivery_date`,DATE_ADD(`delivery_date`, INTERVAL 10 DAY) AS used_day FROM `sales_orders` so INNER JOIN `sales_order_lines` sol ON so.id = sol.`sales_orders_id` WHERE sol.`parent_id` IS NULL AND so.id = '$id'"; $result = mysqli_query($connect, $sql); $degree = "STORAGE: KEEP REFRIGERATED BELOW 5`C"; //var_dump($degree); while($row = mysqli_fetch_array($result)) { //$so_name = $row['so_name']; $sol_name[] = $row['sol_name']; $sol_quantity[] = $row['sol_quantity']; $sol_quantityy = $row['sol_quantity']; $delivery_date[] = $row['delivery_date']; $used_day[] = $row['used_day']; } foreach($sol_quantity as $index => $value) { for($i=1; $i <=$value;$i++) { $text = sprintf( "%s\n%s %s\n%s %s\n%s\n%s", "$sol_name[$index]","<br>", 'Delivery Date', "<br>", 'Use By Date', "<br>", "$delivery_date[$index]","<br>", "$used_day[$index]","<br>", 'PRODUCT OF SOUTH AFRICA',"<br>", "{$degree}" ); $sol_quantity[] for all three products here is 3 . It is returning CARROT & POTATO MIX Delivery Date Use By Date 2021-09-07 POTATO Delivery Date Use By Date 2021-09-07 POTATO Delivery Date Use By Date 2021-09-07 ONION Delivery Date Use By Date 2021-09-07 Instead of CARROT & POTATO MIX Delivery Date Use By Date 2021-09-07 CARROT & POTATO MIX Delivery Date Use By Date 2021-09-07 CARROT & POTATO MIX Delivery Date Use By Date 2021-09-07 POTATO Delivery Date Use By Date 2021-09-07 POTATO Delivery Date Use By Date 2021-09-07 POTATO Delivery Date Use By Date 2021-09-07 ONION Delivery Date Use By Date 2021-09-07 ONION Delivery Date Use By Date 2021-09-07 ONION Delivery Date Use By Date 2021-09-07
  8. foreach ($objPHPExcel->getActiveSheet() as $worksheet) { exactly why i need guidiance . it one sheet with lotsa data all rows filled int till g500 but i know that word is somewhere in column A so i want to search Column A for that word.
  9. does getActiveSheet() return multiple values? - yes - not to be forward - but you keep asking questions but never give answers or point in a direction, are there any other people on this forum that actually code in php?
  10. but it does not return anything - says there is nothing although it is in a20?
  11. oreach is only for multiple values. Does getActiveSheet() return multiple values? how else will i search the excell for the string - 'INACTIVE MEMBERS' and return in what cell it is
  12. got this right with $q = count(glob("$directory/*")) == 0; if ($q) { echo "the folder is empty"; } else {
  13. this pasrt of the code is where i am trying to search for the string //get INACTIVE MEMBERS $foundInCells = array(); $searchValue = 'INACTIVE MEMBERS'; foreach ($objPHPExcel->getActiveSheet() as $worksheet) { $ws = $worksheet->getTitle(); foreach ($worksheet->getRowIterator() as $row) { $cellIterator = $row->getCellIterator(); $cellIterator->setIterateOnlyExistingCells(true); foreach ($cellIterator as $cell) { if ($cell->getValue() == $searchValue) { $foundInCells[] = $ws . '!' . $cell->getCoordinate(); } } } } echo "<br>"; echo "<br>"; echo "this is where - - "; var_dump($foundInCells); echo "<br>"; echo "<br>";
  14. Hi there I have started using php excell and getting most of it right. But i am struggling to search active sheet and return what cell the string is in. below is my code. <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); set_time_limit(0); $directory = "/var/www/html/csvex/xls/"; $formatdirectory = "/var/www/html/csvex/toformat/"; $finishedformatdirectory = "/var/www/html/csvex/formatted/"; $savanadirectory = "/var/www/html/iretire/files/upload/1/"; $main = "/var/www/html/csvex/"; $files = scandir($directory, SCANDIR_SORT_DESCENDING); $newest_file = $files[0]; echo $newest_file; echo "<br>"; $oldfile = $directory.$newest_file; $newfile = $formatdirectory.$newest_file; $changedfile = $finishedformatdirectory.$newest_file; $crmfile = $savanadirectory.$newest_file; echo $oldfile; echo "<br>"; echo $newfile; echo "<br>"; if( !rename($oldfile, $newfile) ) { echo "File can't be moved!"; } else { echo "File has been moved!"; } //format the file date_default_timezone_set('Europe/London'); set_include_path(get_include_path() . PATH_SEPARATOR . './Classes/'); include 'PHPExcel/IOFactory.php'; $fileType = 'Excel5'; $fileName = $newfile; // Read the file $objReader = PHPExcel_IOFactory::createReader($fileType); $objPHPExcel = $objReader->load($fileName); //change font $objPHPExcel->getActiveSheet()->getStyle('a1:a6')->applyFromArray( $styleArray = array( 'font' => array( 'bold' => true ) ) ); $objPHPExcel->getActiveSheet()->getStyle('a6:aa6')->applyFromArray( $styleArray = array( 'font' => array( 'bold' => true ) ) ); $objPHPExcel->getActiveSheet()->getStyle('n16:aa16')->applyFromArray( $styleArray = array( 'font' => array( 'bold' => true ) ) ); //get INACTIVE MEMBERS $foundInCells = array(); $searchValue = 'INACTIVE MEMBERS'; foreach ($objPHPExcel->getActiveSheet() as $worksheet) { $ws = $worksheet->getTitle(); foreach ($worksheet->getRowIterator() as $row) { $cellIterator = $row->getCellIterator(); $cellIterator->setIterateOnlyExistingCells(true); foreach ($cellIterator as $cell) { if ($cell->getValue() == $searchValue) { $foundInCells[] = $ws . '!' . $cell->getCoordinate(); } } } } echo "<br>"; echo "<br>"; echo "this is where - - "; var_dump($foundInCells); echo "<br>"; echo "<br>"; // $objPHPExcel->getActiveSheet()->getStyle('a20')->applyFromArray( $styleArray = array( 'font' => array( 'bold' => true ) ) ); its located at //Get inactive members. another one i am struggling with is to see if file exists if not then do nothing if it does run the code.
  15. <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); set_time_limit(0); $directory = "/var/www/html/default/csvex/xls/"; $formatdirectory = "/var/www/html/default/csvex/toformat/"; $finishedformatdirectory = "/var/www/html/default/csvex/formatted/"; $files = scandir($directory, SCANDIR_SORT_DESCENDING); $newest_file = $files[0]; echo $newest_file; echo "<br>"; $oldfile = $directory.$newest_file; $newfile = $formatdirectory.$newest_file; $changedfile = $finishedformatdirectory.$newest_file; echo $oldfile; echo "<br>"; echo $newfile; echo "<br>"; if( !rename($oldfile, $newfile) ) { echo "File can't be moved!"; } else { echo "File has been moved!"; } chmod($newfile, 755); //format the file date_default_timezone_set('Europe/London'); set_include_path(get_include_path() . PATH_SEPARATOR . './Classes/'); include 'PHPExcel/IOFactory.php'; $fileType = 'Excel5'; $fileName = $newfile; // Read the file $objReader = PHPExcel_IOFactory::createReader($fileType); $objPHPExcel = $objReader->load($fileName); $objPHPExcel->getActiveSheet()->getStyle('d1:d9')->applyFromArray( array('fill' => array( 'type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('argb' => 'ffffffff') ), ) ); // Change the file $objPHPExcel->setActiveSheetIndex(0) ->setCellValue('d1', 'booya') ->setCellValue('d9', 'ddddddddddddddddddd!'); // Write the file $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $fileType); $objWriter->save($fileName); ?>
×
×
  • 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.