Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(session_id() == '') {
- session_start();
- }
- $config = parse_ini_file("config.ini",true);
- $logindata = array();
- $logindata['gebruiker'] = $config['Database']['username'];
- $logindata['server'] = $config['Database']['server'];
- if($config['Database']['password']!=null && $config['Database']['password']!=""){
- $logindata['wachtwoord'] = $config['Database']['password'];
- }else{
- $logindata['wachtwoord'] = null;
- }
- $logindata['database'] = $config['Database']['database'];
- $database = mysql_connect($logindata['server'],$logindata['gebruiker'],$logindata['wachtwoord']);
- if(!$database){
- echo mysql_error();
- die('Could not connect to database');
- }
- if(!mysql_select_db($logindata['database'], $database)){
- die(mysql_error().' Database error<br>');
- }
- showALLVOTES();
- echo('<br>');
- showMONTHLYVOTES();
- checkSearch();
- function checkSearch(){
- global $database,$logindata;
- echo('<form method="post" action=""><input type="text" name="playername" placeholder="Player"><input type="submit" value="Search"></form><br>');
- if(!isset($_POST['playername'])){
- return;
- }
- $sql = "SELECT * FROM `ALLVOTES` WHERE PLAYER LIKE '".$_POST['playername']."' ORDER BY VOTES DESC";
- $query = mysql_query($sql,$database);
- if($query==false){
- echo('Error, something wrong with the query<br>');
- echo mysql_error();
- }
- while($row = mysql_fetch_array($query,MYSQL_ASSOC)){
- if($teller==0){
- $teller++;
- echo('<table border="1"><tr>');
- foreach($row as $key => $value){
- echo('<th>'.$key.'</th>');
- }
- echo('</tr>');
- }
- echo('<tr>');
- foreach($row as $key => $value){
- echo('<td>'.$value.'</td>');
- }
- echo('</tr>');
- }
- echo('</table>');
- }
- function showALLVOTES(){
- global $database,$logindata;
- $sql = "SELECT * FROM `ALLVOTES` ORDER BY VOTES DESC";
- $query = mysql_query($sql,$database);
- if($query==false){
- echo('Error, something wrong with the query<br>');
- echo mysql_error();
- }
- while($row = mysql_fetch_array($query,MYSQL_ASSOC)){
- if($teller>11){
- break;
- }
- if($teller==0){
- $teller++;
- echo('<table border="1"><tr>');
- foreach($row as $key => $value){
- echo('<th>'.$key.'</th>');
- }
- echo('</tr>');
- }
- echo('<tr>');
- foreach($row as $key => $value){
- echo('<td>'.$value.'</td>');
- }
- echo('</tr>');
- }
- echo('</table>');
- }
- function showMONTHLYVOTES(){
- global $database,$logindata;
- $sql = "SELECT * FROM `MONTHLYVOTES` ORDER BY VOTES DESC";
- $query = mysql_query($sql,$database);
- if($query==false){
- echo('Error, something wrong with the query<br>');
- echo mysql_error();
- }
- while($row = mysql_fetch_array($query,MYSQL_ASSOC)){
- if($teller>11){
- break;
- }
- if($teller==0){
- $teller++;
- echo('<table border="1"><tr>');
- foreach($row as $key => $value){
- if($key=="ID"){
- }else{
- echo('<th>'.$key.'</th>');
- }
- }
- echo('</tr>');
- }
- echo('<tr>');
- foreach($row as $key => $value){
- if($key=="ID"){
- }else{
- echo('<td>'.$value.'</td>');
- }
- }
- echo('</tr>');
- }
- echo('</table>');
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment