Advertisement
tyler569

Untitled

Jul 16th, 2014
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.         <head>
  4.                 <title>SQL Test</title>
  5.                 <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
  6.                 <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
  7.                 <meta name="viewport" content="width=device-width, initial-scale=1">
  8.         </head>
  9.         <body>
  10.         <div class="container">
  11.  
  12.         <h2>SQL Test</h2>
  13.  
  14.         <?php
  15.  
  16.                 function generateRandomString($length = 10) {
  17.                         $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  18.                         $randomString = '';
  19.                         for ($i = 0; $i < $length; $i++) {
  20.                                 $randomString .= $characters[rand(0, strlen($characters) - 1)];
  21.                         }
  22.                         return $randomString;
  23.                 }
  24.  
  25.                 $con = mysqli_connect("mariadb","super","AXpbZ5XlkL8i1KT9","test");
  26.  
  27.                 // Check connection
  28.                 if (mysqli_connect_errno())
  29.                 {
  30.                         echo "Failed to connect to MySQL: " . mysqli_connect_error();
  31.                 }
  32.  
  33.                 $randtxt = generateRandomString();
  34.                 $randint = rand(0, 2147483647);
  35.  
  36.                 mysqli_query($con,"INSERT INTO table_1(col1, col2) VALUES ('$randtxt', $randint);");
  37.  
  38.                 $result = mysqli_query($con,"SELECT * FROM table_1;");
  39.  
  40.                 echo "<table class=\"table table-hover\">";
  41.                 echo "<tr><th>Text</th>";
  42.                 #echo "<th>B64 decode</th>";
  43.                echo "<th>Number</th>";
  44.                 #echo "<th>Fraction</th></tr>";
  45.                while($row = mysqli_fetch_array($result)) {
  46.                         echo "<tr>";
  47.                         echo "<td>" . $row['col1'] . "</td>";
  48.                         #echo "<td>" . base64_decode($row['col1']) . "</td>";
  49.                        echo "<td>" . $row['col2'] . "</td>";
  50.                         #echo "<td>" . $row['col2'] / 2147483647 . "</td>";
  51.                        echo "</tr>\n";
  52.                 }
  53.                 echo "</table>";
  54.  
  55.                 mysqli_close($con);
  56.  
  57.         ?>
  58.  
  59.         </div>
  60.         </body>
  61. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement