Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. Your program structure should look like this require 'tcpdf.php' database connection define class MYPDF handle POST request single query to get all required data initialize pdf doc foreach order_id add new page outout invoice for order_id end foreach output pdf doc
  2. ... as this is an English-speaking site.
  3. Try specifying the image path from your site's root, not the file system root. ie "/news/img/posts/"
  4. Your first one is missing a } before the else. Syntax is if (condition) { do something } else { do something else } It looks like $em is not valid. Have you tried var_dump($em) to check what's in there? PS You could just... if ( ($em = filter_var($em, FILTER_VALIDATE_EMAIL)) === false ) { echo "Invalid format"; }
  5. You have already posted this question. Closing.
  6. This is the method I use, storing the data in an array indexed by parentId No need to store the "level". It works that out itself. Store the "left-margin" values for each level in the css.
  7. Have you checked the value in $image_ext?
  8. Make sure you have defined the function insert(). It's not a PHP function. (Or did you mean isset() ?)
  9. If you are uploading a file you should be using the $_FILES array, not $_POST for the image.
  10. I see two syntax errors if (insert($_POST['register_button'])) { The { has no corresponding } later in the code. if (filter_var($em, FILTER_VALIDATE_EMAIL)) { $em = filter_var($em, FILTER_VALIDATE_EMAIL) ^ } missing ; at the end of the line
  11. A couple of points about your processing: 1 ) As your first heading is "lmk_key" and the second is "address1", it appears that the data actually starts halfway through element 89, and that somewhere along the way whatever split the headings from the data has become a space character 2 ) Exploding on "," isn't working as the address data itself contains a comma, thus splitting that data over two elements ... [89] => low-energy-fixed-light-count 1229391483952014103108154495749528 [90] => "142 [91] => Edgar Road" Better to use str_getcsv() which knows how to process ... , "142, Edgar Road", ... If I change that space in the middle of element 89 to a |, then $str = 'lmk-key,address1,address2,address3,postcode,building-reference-number,current-energy-rating,potential-energy-rating,current-energy-efficiency,potential-energy-efficiency,property-type,built-form,inspection-date,local-authority,constituency,county,lodgement-date,transaction-type,environment-impact-current,environment-impact-potential,energy-consumption-current,energy-consumption-potential,co2-emissions-current,co2-emiss-curr-per-floor-area,co2-emissions-potential,lighting-cost-current,lighting-cost-potential,heating-cost-current,heating-cost-potential,hot-water-cost-current,hot-water-cost-potential,total-floor-area,energy-tariff,mains-gas-flag,floor-level,flat-top-storey,flat-storey-count,main-heating-controls,multi-glaze-proportion,glazed-type,glazed-area,extension-count,number-habitable-rooms,number-heated-rooms,low-energy-lighting,number-open-fireplaces,hotwater-description,hot-water-energy-eff,hot-water-env-eff,floor-description,floor-energy-eff,floor-env-eff,windows-description,windows-energy-eff,windows-env-eff,walls-description,walls-energy-eff,walls-env-eff,secondheat-description,sheating-energy-eff,sheating-env-eff,roof-description,roof-energy-eff,roof-env-eff,mainheat-description,mainheat-energy-eff,mainheat-env-eff,mainheatcont-description,mainheatc-energy-eff,mainheatc-env-eff,lighting-description,lighting-energy-eff,lighting-env-eff,main-fuel,wind-turbine-count,heat-loss-corridor,unheated-corridor-length,floor-height,photo-supply,solar-water-heating-flag,mechanical-ventilation,address,local-authority-label,constituency-label,posttown,construction-age-band,lodgement-datetime,tenure,fixed-lighting-outlets-count,low-energy-fixed-light-count|1229391483952014103108154495749528,"142, Edgar Road",,,TW4 5QP,5844359278,D,C,61,73,Maisonette,End-Terrace,2014-10-30,E09000027,E14001005,Greater London Authority,2014-10-31,marketed sale,57,73,241,152,4,46,2.5,56,56,747,473,155,125,87,Single,Y,3rd,Y,,2104,100,double glazing installed during or after 2002,Normal,0,5,5,100,0,From main system,Good,Good,"Solid, no insulation (assumed)",N/A,N/A,Fully double glazed,Good,Good,"Cavity wall, as built, no insulation (assumed)",Poor,Poor,None,N/A,N/A,"Flat, limited insulation (assumed)",Very Poor,Very Poor,"Boiler and radiators, mains gas",Good,Good,Programmer and room thermostat,Average,Average,Low energy lighting in all fixed outlets,Very Good,Very Good,mains gas (not community),1,unheated corridor,5,,0,,natural,"142, Edgar Road",Richmond upon Thames,Twickenham,HOUNSLOW,England and Wales: 1967-1975,2014-10-31 08:15:44,owner-occupied,11,11'; $arr = []; foreach (explode('|', $str) as $line) { $arr[] = str_getcsv($line); } echo '<pre>' . print_r(array_combine($arr[0], $arr[1]), 1) . '</pre>'; outputting... Array ( [lmk-key] => 1229391483952014103108154495749528 [address1] => 142, Edgar Road [address2] => [address3] => [postcode] => TW4 5QP [building-reference-number] => 5844359278 [current-energy-rating] => D [potential-energy-rating] => C [current-energy-efficiency] => 61 [potential-energy-efficiency] => 73 [property-type] => Maisonette [built-form] => End-Terrace [inspection-date] => 2014-10-30 [local-authority] => E09000027 [constituency] => E14001005 [county] => Greater London Authority [lodgement-date] => 2014-10-31 . . . etc }
  12. I get the impression that there should be 2 arrays in that data. The first 90 or so elements look like headings and the final 90 look like data. Could be there is something like a "\n" in the middle that isn't showing. You may need 2 explodes. The first to split the results into records and the second to split those records into fields.
  13. The string you posted appears to be missing its enclosing { .. }. With those it becomes a correctly formatted JSON string... $details = '{"customer_details":{"email":"[email protected]","tax_exempt":"none","tax_ids":[]}}'; you can then decode the string... $data = json_decode($details); then access the email address with... $email = $data->customer_details->email;
  14. Everything you need is here... https://www.php.net/manual/en/ https://dev.mysql.com/doc/refman/5.7/en/introduction.html
  15. Looks like you've found the answer by yourself
  16. You can't embed php code in the middle of a string like that. You could do... $htmlcontent .=" <tr> <td>".$year."</td> <td align=\"center\"> "; if(count($singlecount[$year])>0) { $htmlcontent .= (count($singlecount[$year])); } else { $htmlcontent .= "-"; } $htmlcontent .= "</td>"; // etc
  17. You could try something like this $temp = json_decode($invoice_data); unset($temp->shipment_data[0]->cost_revenue_items[2]); $new_inv_data = json_encode($temp); echo '<pre>' . print_r($temp, 1) . '</pre>'; giving stdClass Object ( [CONTACT_ID] => 1 [INV_SERIAL_NO] => 100 [NAME] => baby [INV_DATE] => 2018-06-27 [DUE_DATE] => 2018-06-27 [CURRENCY] => KD [SUBTOTAL] => 143 [TAX_TOTAL] => 13 [shipment_data] => Array ( [0] => stdClass Object ( [SHIP_SERIAL_NO] => 44 [MASTER_NO] => 55 [HOUSE_NO] => 88 [cost_revenue_items] => Array ( [0] => stdClass Object ( [CHARGE_REF] => tt [CURRENCY] => INR [QUANTITY] => 2 [SELLING_RATE] => 45 [EXCHANGE_RATE] => 987 ) [1] => stdClass Object ( [CHARGE_REF] => ii [CURRENCY] => INR [QUANTITY] => 2 [SELLING_RATE] => 45 [EXCHANGE_RATE] => 456 ) ) ) ) )
  18. I would check that the query being executed is the one I think is being executed if ($_POST['btn-remove']) { $id_user=$_SESSION['id_user']; $id_prod = $_POST['id_prod']; $SQLREM = "DELETE FROM `carrito` WHERE id_user='$id_user' and id_producto='$id_prod';"; echo $SQLREM; exit; }
  19. Do not put quotes around placeholders. You do not want them treated as string literals
  20. Put this line of code just before your mysqi_connect() line. mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); So long as you have error display turned on, that will tell you if any mysql errors occured
  21. The clue is in the function name. imagecreatefrompng() is for creating GD images from a PNG file. Check the manual and see if can find a similar function that might be suitable for reading a jpg file. Once you have created the image, you can then output it as a png file.
  22. If all the PDFs are destined for the same user you could write multiple documents to one file, starting each on a new page. If they need to be separate then you could write them to the server as individual files and return links to those files. The documentation may tell you if you can download multiple, individual files - if you can find it. The only documentation I have found is the function comments in the class source file itself. Surely the worst documented package out there. Their site links you to manual search feature. Attempting to search for "TCPDF manual" resuts in a list of just about every manual (domestic appliances, cars, components, heart monitors etc etc) that has been produced in PDF format. Not helpful.
  23. The code I gave you before works with version 8, if you change the WHERE clause to what you really want instead of what you said you wanted... WHERE insert_time > NOW() - INTERVAL 60 MINUTE AND user_id = 4 Try it with fclose($fp); instead of echo $result; It should give a dialogue box asking if you want to open or save.
  24. It also gives a better structure to the resulting array, to make those with numbered keys a sub-group Array ( [products] => Array ( [77777] => Array ( [newQuantity] => 3 [newPrice] => 5 [usedQuantity] => 1 [usedPrice] => 3.99 [total] => 18.99 ) [88888] => Array ( [newQuantity] => 0 [newPrice] => 0 [usedQuantity] => 4 [usedPrice] => 12 [total] => 48 ) [44444] => Array ( [newQuantity] => 2 [newPrice] => 4 [usedQuantity] => 0 [usedPrice] => 3.99 [total] => 8 ) ) [date] => July 25 2021 [address] => 123 Anystreet Avenue [address2] => [zipcode] => 90210 [city] => Beverly Hills [state] => CA [planet] => Mars )
  25. PS It would better to change line 6 above to $sku['products'][$id][$k] = $v;
×
×
  • 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.