Advertisement
Guest User

Untitled

a guest
Apr 6th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. <?php
  2. header('Content-type: text/xml');
  3. // Määrame lehe tüübiks XMLi
  4. // Andmebaasiga ühendamine
  5. $host = "localhost";
  6. $user = "disainee_wp680";
  7. $pass = "9]Sj)p29MXx";
  8. $database = "disainee_wp680";
  9. $con = mysqli_connect($host, $user, $pass, $database);
  10. if(mysqli_connect_errno()){
  11. trigger_error('Database connection failed: ' . mysqli_connect_error(), E_USER_ERROR);
  12. }
  13.  
  14. // Määrame, millise charsetiga töötame.
  15. mysqli_set_charset($con, 'utf-8');
  16.  
  17.  
  18. $queryID = "SELECT * FROM fb_customers WHERE klient = 'Aet Laredei'"; //
  19.  
  20. $resultID = mysqli_query($con, $queryID);
  21.  
  22. // Hakkame saadud tellimuse numbri järgi infot väljastama ja XML'i komplekteerima.
  23.  
  24. $xml_output = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
  25. $xml_output .= "<invoices>\n";
  26.  
  27. while($row = mysqli_fetch_array($resultID)){
  28. $xml_output .= "\t";
  29. $xml_output .= '<invoice customer_name="'.$row['klient'].'">';
  30. $xml_output .= "\n";
  31.  
  32.  
  33. // Hakkame tellitud toodete ridasid komplekteerima.
  34.  
  35. $queryLine = "SELECT * FROM fb_orders WHERE tellija = 'Aet Laredei'";
  36. $resultLine = mysqli_query($con, $queryLine);
  37. $i = 0;
  38. while($rowLine = mysqli_fetch_array($resultLine)){
  39. $i++;
  40. $xml_output .= "\t\t";
  41.  
  42.  
  43. $xml_output .= '<line price="'.$rowLine['hind'].'"';
  44.  
  45.  
  46. $xml_output .= ' product="'.$rowLine['toode'].'"';
  47. $xml_output .= ' size="'.$rowLine['suurus'].'"';
  48. $xml_output .= ' color="'.$rowLine['varv'].'" />';
  49. $xml_output .= "\n";
  50. }
  51.  
  52. $i++;
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59. $xml_output .= "\t\t";
  60.  
  61. $xml_output .= "\n\t</invoice>\n";
  62. }
  63. $xml_output .= "</invoices>";
  64.  
  65.  
  66. echo $xml_output;
  67.  
  68. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement