Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="pl">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title> php </title>
  6. <style type="text/css">
  7. table,td{
  8. border-style:solid;
  9. border-collapse:collapse;
  10. }
  11. tr:nth-child(2n){
  12. background-color:#f2afbf;
  13. }
  14.  
  15. tr:nth-child(2n+1){
  16. background-color:#d1cfdf;
  17. }
  18.  
  19. </style>
  20. </head>
  21. <body>
  22. <?php
  23. $str='<table>';
  24. $plik=file("produkty.txt");
  25. $n=count($plik);
  26. for($i=0; $i<$n;$i++){
  27. $str.='<tr>';
  28. $elementy=explode("\t",$plik[$i]);
  29. for($j=0;$j<5;$j++){
  30. $str.='<td>'.$elementy[$j].'</td>';
  31. if($i!=0 && $j==4) $cena+=$elementy[$j];
  32. }
  33. $str.='</tr>';
  34. }
  35. $str.='</table>';
  36.  
  37. echo $str;
  38. echo 'wartosc produktow: '.$cena;
  39. ?>
  40. </body>
  41. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement