Advertisement
Guest User

get_feedback.php

a guest
Oct 28th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.25 KB | None | 0 0
  1.  <?php
  2.  
  3.       $servername = "localhost";
  4.       $username = "root";
  5.       $password = "root";
  6.       $database = "dummyServer";
  7.       // Create connection
  8.       $conn = mysqli_connect($servername, $username, $password,$database);
  9.       // Check connection
  10.       if (!$conn)
  11.       {
  12.         die("Connection failed: " . mysqli_connect_error());
  13.       }
  14.       //echo "Connected successfully ";
  15.  
  16.       if ($_SERVER["REQUEST_METHOD"] == "POST")
  17.       {
  18.         $id = urldecode($_POST['Id']);
  19.         //$id=1;
  20.         $sql = "SELECT feedback from INFORMATION WHERE id = ".$id;
  21.         //echo $sql;
  22.         $result = mysqli_query($conn, $sql);
  23.        
  24. $xml=<<<XML
  25. <Information></Information>
  26. XML;
  27.     $xml=simplexml_load_string($xml);
  28.    
  29.     if (mysqli_num_rows($result) > 0)
  30.     {
  31.       $i=0;
  32.       // output data of each row
  33.       while($row = mysqli_fetch_assoc($result))
  34.       {
  35.         $xml->addChild("Feedbacks");
  36.         $xml->Feedbacks[$i]->addChild("feedback",$row["feedback"]);
  37.         $i=$i+1;
  38.       }
  39.     }
  40.       $dom = new DOMDocument("1.0");
  41.       $dom->preserveWhiteSpace = false;
  42.       $dom->formatOutput = true;
  43.       $dom->loadXML($xml->asXML());
  44.       echo "<pre>".htmlentities($dom->saveXML())."</pre>";
  45.       }
  46.     ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement