Guest User

link.php

a guest
Nov 15th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.38 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Shared Link</title>
  5.    
  6.     <meta http-equiv="Content-Type" content="text/html; charset=utf8">
  7.     <meta name="viewport" content="width=device-width, initial-scale=1">
  8.     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
  9.     <script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
  10.     <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
  11.     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
  12.     <link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
  13.     <link href='https://fonts.googleapis.com/css?family=Noto+Sans' rel='stylesheet' type='text/css'>
  14.     <link rel="stylesheet" type="text/css" href="http://cdn.datatables.net/1.10.13/css/jquery.dataTables.css">
  15.     <script type="text/javascript" charset="utf8" src="http://cdn.datatables.net/1.10.13/js/jquery.dataTables.js"></script>
  16. </head>
  17. <style type="text/css">
  18.     body{
  19.         overflow-x: hidden;
  20.         padding: 5px;
  21.     }
  22. </style>
  23. <?php
  24.     header("Content-type: text/html; charset=utf-8");
  25.     $host ="localhost";
  26.     $user="kelvin";
  27.     $password="26467790";
  28.     $database="bacbac";
  29.     $con = mysql_connect($host, $user, $password);
  30.     header("Content-Type: text/html; charset=utf-8");
  31.     if (!$con){
  32.         echo "Cannot connect db: ".mysql_error($con);
  33.         exit();
  34.     }
  35.     mysql_set_charset('utf8');
  36.     $db_selected = mysql_select_db( $database);
  37.     if (!$db_selected){
  38.         echo "Cannot select db: " . mysql_error($con);
  39.         exit();
  40.     }
  41.     $query="SELECT `link`,name,`by`,`date`,`cat`,`vote` FROM sharedlink order by `vote` DESC";
  42.     $result=mysql_query($query);
  43.     $rows = Array();
  44.     while($row=mysql_fetch_array($result)){
  45.         $rows[] = $row;
  46.     }
  47.     $data = json_encode($rows);
  48.    
  49. ?>
  50. <script>
  51. $(document).ready(function(){
  52.     $('#table').dataTable({
  53.     data:<?php echo $data?>,
  54.     columns: [
  55.         { data: 'link' },
  56.         { data: 'name' },
  57.         { data: 'by' },
  58.         { data: 'date' },
  59.         { data: 'cat' },
  60.         { data: 'vote' }
  61.     ],
  62.     dom: 'Bfrtip',
  63.     buttons: [
  64.     'csvHtml5'
  65.     ],
  66.     paging: false,
  67.     "createdRow": function ( row, data, index ) {
  68.             $('td', row).eq(0).html('<a href="'+data[0]+'">'+'Link'+'</a>');
  69.     }
  70.     });
  71. });
  72. </script>
  73. <body>
  74.     <table class='table table-striped table-bordered table-hover dataTable no-footer' style='width:0%' align='center' id='table'>
  75.        <thead>
  76.            <tr>
  77.                <th style="width:">
  78.                 Link
  79.                </th>
  80.                <th>
  81.                 Name
  82.                </th>
  83.                <th>
  84.                 by
  85.                </th>
  86.                <th>
  87.                 Date
  88.                </th>
  89.                <th>
  90.                 Category
  91.                </th>
  92.                <th>
  93.                 Vote
  94.                </th>
  95.            </tr>
  96.        </thead>
  97.         </table>
Add Comment
Please, Sign In to add comment