View difference between Paste ID: CVym5B5b and U2FVKyck
SHOW: | | - or go back to the newest paste.
1
<?php
2
if(session_id() == '') {
3
	session_start();
4
	}
5
$config = parse_ini_file("config.ini",true);
6
$logindata = array();
7
$logindata['gebruiker'] = $config['Database']['username'];
8
$logindata['server'] = $config['Database']['server'];
9
if($config['Database']['password']!=null && $config['Database']['password']!=""){
10
	$logindata['wachtwoord'] = $config['Database']['password'];
11
}else{
12
	$logindata['wachtwoord'] = null;
13
}
14
$logindata['database'] = $config['Database']['database'];
15
$database = mysql_connect($logindata['server'],$logindata['gebruiker'],$logindata['wachtwoord']);
16
if(!$database){
17
	echo mysql_error();
18
	die('Could not connect to database');
19
}
20
if(!mysql_select_db($logindata['database'], $database)){		
21
	die(mysql_error().' Database error<br>');
22
}
23
showALLVOTES();
24
echo('<br>');
25
showMONTHLYVOTES();
26
checkSearch();
27-
	$sql = "SELECT * FROM `ALLVOTES` ORDER BY nummer";
27+
28
29
function checkSearch(){
30
	global $database,$logindata;
31
	echo('<form method="post" action=""><input type="text" name="playername" placeholder="Player"><input type="submit" value="Search"></form><br>');
32
	if(!isset($_POST['playername'])){
33
		return;
34
	}
35-
			$teller=1;
35+
	$sql = "SELECT * FROM `ALLVOTES` WHERE PLAYER LIKE '".$_POST['playername']."' ORDER BY VOTES DESC";
36
	$query = mysql_query($sql,$database);
37
	if($query==false){
38
		echo('Error, something wrong with the query<br>');
39
		echo mysql_error();
40
	}
41
	while($row = mysql_fetch_array($query,MYSQL_ASSOC)){
42
		if($teller==0){
43
			$teller++;
44
			echo('<table border="1"><tr>');
45
			foreach($row as $key => $value){
46
				echo('<th>'.$key.'</th>');
47
			}
48
			echo('</tr>');
49
		}
50
		echo('<tr>');
51
		foreach($row as $key => $value){
52
			echo('<td>'.$value.'</td>');
53-
	$sql = "SELECT * FROM `MONTHLYVOTES` ORDER BY nummer";
53+
54
		echo('</tr>');
55
	}
56
	echo('</table>');
57
}
58
59
function showALLVOTES(){
60
	global $database,$logindata;
61-
			$teller=1;
61+
	$sql = "SELECT * FROM `ALLVOTES` ORDER BY VOTES DESC";
62
	$query = mysql_query($sql,$database);
63
	if($query==false){
64
		echo('Error, something wrong with the query<br>');
65
		echo mysql_error();
66
	}
67
	while($row = mysql_fetch_array($query,MYSQL_ASSOC)){
68
		if($teller>11){
69
			break;
70
		}
71
		if($teller==0){
72
			$teller++;
73
			echo('<table border="1"><tr>');
74
			foreach($row as $key => $value){
75
				echo('<th>'.$key.'</th>');
76
			}
77
			echo('</tr>');
78
		}
79
		echo('<tr>');
80
		foreach($row as $key => $value){
81
			echo('<td>'.$value.'</td>');
82
		}
83
		echo('</tr>');
84
	}
85
	echo('</table>');
86
}
87
88
function showMONTHLYVOTES(){
89
	global $database,$logindata;
90
	$sql = "SELECT * FROM `MONTHLYVOTES` ORDER BY VOTES DESC";
91
	$query = mysql_query($sql,$database);
92
	if($query==false){
93
		echo('Error, something wrong with the query<br>');
94
		echo mysql_error();
95
	}
96
	while($row = mysql_fetch_array($query,MYSQL_ASSOC)){
97
		if($teller>11){
98
			break;
99
		}
100
		if($teller==0){
101
			$teller++;
102
			echo('<table border="1"><tr>');
103
			foreach($row as $key => $value){
104
			if($key=="ID"){
105
			}else{
106
				echo('<th>'.$key.'</th>');
107
			}
108
			}
109
			echo('</tr>');
110
		}
111
		echo('<tr>');
112
		foreach($row as $key => $value){
113
			if($key=="ID"){
114
			}else{
115
			echo('<td>'.$value.'</td>');
116
			}
117
		}
118
		echo('</tr>');
119
	}
120
	echo('</table>');
121
}
122
123
?>