Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.93 KB | None | 0 0
  1. <?php
  2.     header('Content-Type: text/xml');  # create header
  3.   error_reporting(E_ALL);
  4.    
  5.    $dbhost = "localhost";
  6.    $dbuser = "alf5525";
  7.    
  8.    $mysqli = new mysqli($dbhost,$dbuser,*******,$dbUser);
  9.    
  10.    echo "<xml>";
  11.    
  12.     getDescription($mysqli);
  13.  
  14.    
  15.    
  16.    
  17.    
  18.    function getDescription($mysqli)
  19.    {
  20.    $sql = "SELECT * FROM TableInfo WHERE DataID = '1'";
  21.     if ($result = $mysqli->query($sql))
  22.      //got a result
  23.         //work with the results
  24.         echo "<tr> <td> there were ".$result->num_rows." rows </td></tr>\n";
  25.         if ($result->num_rows >0)
  26.         {
  27.            
  28.             //build up the rows in the table
  29.             while ($row = $result->fetch_object())
  30.             {
  31.                 $desc = $row->description;
  32.                
  33.                
  34.                 echo "<description>\n";
  35.                 echo "$desc \n";
  36.                 echo "</description>";
  37.                
  38.             }
  39.        
  40.         }  
  41.        
  42.         else { //error with the submitted query
  43.         echo "no results";
  44.     }
  45. }
  46.    
  47.    
  48.    echo "</xml>";
  49.    
  50.    $mysqli->close();
  51.  ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement