Don't like ads? PRO users don't see any ads ;-)

teo

By: delmoras on Jul 13th, 2012  |  syntax: PHP  |  size: 0.88 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. header("Content-type: text/xml");
  4. // EDO THA VALEIS CONNECT GIA MYSQL KLP
  5.  
  6. // AFTI I FUNCTION KANEI ENCODE TO XML
  7. function xmlencode($string) {
  8.     //
  9.     //$string = str_replace("<", "&lt;", $string);
  10.     $string = strip_tags($string);
  11.     $string = str_replace("&", "", $string);
  12.     $string = str_replace(" ","",$string);
  13.     return $string;
  14. }
  15.  
  16. ?>
  17. <?php echo '<?xml version="1.0" encoding="utf-8"?>
  18. '; ?>
  19. <THODORIS name="ninja" url="www.ninja.com" encoding="utf8">
  20.     <products>
  21.         <?
  22.         //p.x. theleis na trexeis ena query gia ta x kai y opote to grafeis edo kai meta tiponeis ta     //elements sou kai esai etoimos
  23.         $sql = "SELECT * FROM ninja WHERE name = {$_GET['x']} AND lastname = {$_GET['y']}";
  24.         $res = mysql_query($sql);
  25.         while($row = mysql_fetch_array($res))
  26.         {
  27.                 echo "<item>".xmlencode($row['name'])."</item>";
  28.         }
  29.         ?>
  30.     </products>
  31. </THODORIS>