Iets uitrekenen met database
SELECT
*
FROM
clips
ORDER BY
total_value/total_votes DESC
LIMIT 20
Hier moet iets mee gebeuren waardoor ik total_value laat delen door total_votes weet iemand hoe
En hoe kom je aan total_value en total_votes? Zijn dat kolommen in je tabel? Als dat namelijk zo is, zou bovenstaande gewoon moeten werken...
<td class='capmain'>Welkom</td>
</tr>
<tr>
<td class='main-body'>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
$titel = "Beginpagina";
echo "<table width=\"100%\">
<tr>
<td width=\"50%\" valign=\"top\">
<h2>20 Hoogst gerate tracks</h2>";
$bekeken_select = mysql_query("
SELECT
*
FROM
clips
ORDER BY
total_value/total_votes DESC
LIMIT 20
") or die(mysql_error());
$color = array( '#343434', '#2e2e2e');
$i = 0;
if(!mysql_num_rows($bekeken_select))
{
echo "Er zijn (nog) geen clips.<br />";
}
else
{
echo "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">";
while ($show = mysql_fetch_assoc($bekeken_select))
{
$show['artiest'] = stripslashes($show['artiest']);
$show['artiest'] = htmlentities($show['artiest']);
$show['titel'] = stripslashes($show['titel']);
$show['titel'] = htmlentities($show['titel']);
echo "<tr><td style='background-color: ".$color[ $i ] ."'><a href=\"index.php?pagina=clip&clip=".$show['id']."\">".$show['artiest']." - ".$show['titel']."</a></td>
</tr>";
if( $i > 0 )
{
$i = 0;
}
else
{
$i++;
}
}
echo "</table>";
}
echo "</td>
<td width=\"50%\" valign=\"top\">
<h2>20 Nieuwste tracks</h2>";
$nieuw_select = mysql_query("
SELECT
*
FROM
clips
ORDER BY
id DESC
LIMIT 20
") or die('<b>MySQL Error:</b>'.mysql_error());
$color2 = array( '#2e2e2e', '#343434');
$i = 0;
if(!mysql_num_rows($nieuw_select))
{
echo "Er zijn (nog) geen clips.<br />";
}
else
{
echo "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">";
while ($show2 = mysql_fetch_assoc($nieuw_select))
{
$show2['artiest'] = stripslashes($show2['artiest']);
$show['artiest'] = htmlentities($show2['artiest']);
$show2['titel'] = stripslashes($show2['titel']);
$show2['titel'] = htmlentities($show2['titel']);
echo "<tr><td style='background-color: ".$color2[ $i ] ."'><a href=\"index.php?pagina=clip&clip=".$show2['id']."\">".$show2['artiest']." - ".$show2['titel']."</a></td>
</tr>";
if( $i > 0 )
{
$i = 0;
}
else
{
$i++;
}
}
echo "</table>";
}
echo "</td>
</tr>
</table>";
echo "<hr />";
$advertentie_select = mysql_query("
SELECT
advertentie
FROM
advertenties
WHERE
plaats = 'index'
LIMIT 1
") or die (mysql_error());
while($show3 = mysql_fetch_assoc($advertentie_select))
{
$show3['advertentie'] = stripslashes($show3['advertentie']);
$show3['advertentie'] = nl2br($show3['advertentie']);
echo $show3['advertentie'];
}
mysql_close();
?>
$titel = "Beginpagina";
echo "<table width=\"100%\">
<tr>
<td width=\"50%\" valign=\"top\">
<h2>20 Hoogst gerate tracks</h2>";
$bekeken_select = mysql_query("
SELECT
*
FROM
clips
ORDER BY
total_value/total_votes DESC
LIMIT 20
") or die(mysql_error());
$color = array( '#343434', '#2e2e2e');
$i = 0;
if(!mysql_num_rows($bekeken_select))
{
echo "Er zijn (nog) geen clips.<br />";
}
else
{
echo "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">";
while ($show = mysql_fetch_assoc($bekeken_select))
{
$show['artiest'] = stripslashes($show['artiest']);
$show['artiest'] = htmlentities($show['artiest']);
$show['titel'] = stripslashes($show['titel']);
$show['titel'] = htmlentities($show['titel']);
echo "<tr><td style='background-color: ".$color[ $i ] ."'><a href=\"index.php?pagina=clip&clip=".$show['id']."\">".$show['artiest']." - ".$show['titel']."</a></td>
</tr>";
if( $i > 0 )
{
$i = 0;
}
else
{
$i++;
}
}
echo "</table>";
}
echo "</td>
<td width=\"50%\" valign=\"top\">
<h2>20 Nieuwste tracks</h2>";
$nieuw_select = mysql_query("
SELECT
*
FROM
clips
ORDER BY
id DESC
LIMIT 20
") or die('<b>MySQL Error:</b>'.mysql_error());
$color2 = array( '#2e2e2e', '#343434');
$i = 0;
if(!mysql_num_rows($nieuw_select))
{
echo "Er zijn (nog) geen clips.<br />";
}
else
{
echo "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">";
while ($show2 = mysql_fetch_assoc($nieuw_select))
{
$show2['artiest'] = stripslashes($show2['artiest']);
$show['artiest'] = htmlentities($show2['artiest']);
$show2['titel'] = stripslashes($show2['titel']);
$show2['titel'] = htmlentities($show2['titel']);
echo "<tr><td style='background-color: ".$color2[ $i ] ."'><a href=\"index.php?pagina=clip&clip=".$show2['id']."\">".$show2['artiest']." - ".$show2['titel']."</a></td>
</tr>";
if( $i > 0 )
{
$i = 0;
}
else
{
$i++;
}
}
echo "</table>";
}
echo "</td>
</tr>
</table>";
echo "<hr />";
$advertentie_select = mysql_query("
SELECT
advertentie
FROM
advertenties
WHERE
plaats = 'index'
LIMIT 1
") or die (mysql_error());
while($show3 = mysql_fetch_assoc($advertentie_select))
{
$show3['advertentie'] = stripslashes($show3['advertentie']);
$show3['advertentie'] = nl2br($show3['advertentie']);
echo $show3['advertentie'];
}
mysql_close();
?>
dit is het script
Verder blijft de vraag staan hoe je aan total_values en total_votes komt.
ow wat goed ik ben er zelf achter gekomen dat het werkt