Inner Join
Ik zit met een probleem. Zelf heb ik niet echt heel veel verstand van 'JOIN'. Daar loop ik nu mee vast. Ik heb n.l het volgende:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?
$query= mysql_query("SELECT prefixcolor, suffixcolor, users.id, downloaded, uploaded, username, level, avatar, UNIC_TIMESTAMP(joined) AS joined, UNIX_TIMESTAMP(lastconnect) AS lastconnect, flag, flagpic, name FROM users INNER JOIN users_level ON users.id_level = users_level.id LEFT JOIN countries ON users.flag = countries.id WHERE users.id_level = 15 ORDER BY users.id");
print($query);
$rusers= mysql_query($query);
if (mysql_num_rows($rusers)==0) //line 31
// flag hack
print("<tr><td class=lista colspan=6>Niets gevonden</td></tr>");
else
{
while ($row_user=mysql_fetch_array($rusers))
{
print("<tr>\n");[/code]
Als ik dit invul komt deze fout:
[code]Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mp3start/domains/mp3-start.nl/public_html/torrents/notsponsors.php on line 31[/code]
Kan iemand mij helpen met het goed invullen van INNER JOIN? Bedankt!
$query= mysql_query("SELECT prefixcolor, suffixcolor, users.id, downloaded, uploaded, username, level, avatar, UNIC_TIMESTAMP(joined) AS joined, UNIX_TIMESTAMP(lastconnect) AS lastconnect, flag, flagpic, name FROM users INNER JOIN users_level ON users.id_level = users_level.id LEFT JOIN countries ON users.flag = countries.id WHERE users.id_level = 15 ORDER BY users.id");
print($query);
$rusers= mysql_query($query);
if (mysql_num_rows($rusers)==0) //line 31
// flag hack
print("<tr><td class=lista colspan=6>Niets gevonden</td></tr>");
else
{
while ($row_user=mysql_fetch_array($rusers))
{
print("<tr>\n");[/code]
Als ik dit invul komt deze fout:
[code]Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mp3start/domains/mp3-start.nl/public_html/torrents/notsponsors.php on line 31[/code]
Kan iemand mij helpen met het goed invullen van INNER JOIN? Bedankt!
Verder heb ik alleen haakjes om de JOIN geplaatst.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
SELECT
prefixcolor,
suffixcolor,
users.id,
downloaded,
uploaded,
username,
level,
avatar,
UNIX_TIMESTAMP(joined) AS joined,
UNIX_TIMESTAMP(lastconnect) AS lastconnect,
flag, flagpic, name
FROM
(users
INNER JOIN users_level ON users.id_level = users_level.id)
LEFT JOIN countries ON users.flag = countries.id
WHERE
users.id_level = 15
ORDER BY users.id
prefixcolor,
suffixcolor,
users.id,
downloaded,
uploaded,
username,
level,
avatar,
UNIX_TIMESTAMP(joined) AS joined,
UNIX_TIMESTAMP(lastconnect) AS lastconnect,
flag, flagpic, name
FROM
(users
INNER JOIN users_level ON users.id_level = users_level.id)
LEFT JOIN countries ON users.flag = countries.id
WHERE
users.id_level = 15
ORDER BY users.id
Hij werkt nu wel, alleen nu pakt hij geen getallen die boven de 129 uitkomen, dus 130 en hoger pakt hij niet ???
Gewijzigd op 01/01/1970 01:00:00 door Klaasjan Boven
Nee, int(10)
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
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
<?
$query = mysql_query("SELECT
prefixcolor,
suffixcolor,
users.id,
downloaded,
uploaded,
username,
level,
avatar,
UNIX_TIMESTAMP(joined) AS joined,
UNIX_TIMESTAMP(lastconnect) AS lastconnect,
flag, flagpic, name
FROM
(users
INNER JOIN users_level ON users.id_level = users_level.id)
LEFT JOIN countries ON users.flag = countries.id
WHERE
users.id_level = 15
ORDER BY users.id");
print($query);
$rusers=mysql_query($query);
if (mysql_num_rows($rusers)==0) //line 49
// flag hack
print("<tr><td class=lista colspan=6>Niets gevonden</td></tr>");
else
{
while ($row_user=mysql_fetch_array($rusers))
{
print("<tr>\n");
$avatar = "";
$avatar = ($row_user["avatar"] && $row_user["avatar"] != "" ? htmlspecialchars($row_user["avatar"]) : "");
$userid = $row_user["id"];
$cQuery = mysql_query("SELECT `donations` FROM `donations` WHERE userid=$userid");
if (cQuery)
{
$donatie = mysql_result($cQuery, donations);
}
else
$donatie=0;
$dn = $donatie/100;
if ($dn >= 13)
$d = "images/smilies/thumbsup2.gif";
elseif ($dn >= 6.5)
$d = "images/smilies/grin2.gif";
elseif ($dn >= 3.90)
$d = "images/smilies/smile2.gif";
elseif ($dn >= 2.60)
$d = "images/smilies/noexpression2.gif";
elseif ($dn >= 1.30)
$d = "images/smilies/sad2.gif";
else
$d = "images/smilies/thumbsdown.gif";
$donatie=number_format($dn,2)." <img src=$d>";
if ($dn < $tobed)[/code]
Dit is het script wat Donatie betreft. Met dit ingevuld krijg ik dit als error:
[code]Resource id #77
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mp3start/domains/mp3-start.nl/public_html/torrents/notsponsors.php on line 49[/code]
Vreemd?
$query = mysql_query("SELECT
prefixcolor,
suffixcolor,
users.id,
downloaded,
uploaded,
username,
level,
avatar,
UNIX_TIMESTAMP(joined) AS joined,
UNIX_TIMESTAMP(lastconnect) AS lastconnect,
flag, flagpic, name
FROM
(users
INNER JOIN users_level ON users.id_level = users_level.id)
LEFT JOIN countries ON users.flag = countries.id
WHERE
users.id_level = 15
ORDER BY users.id");
print($query);
$rusers=mysql_query($query);
if (mysql_num_rows($rusers)==0) //line 49
// flag hack
print("<tr><td class=lista colspan=6>Niets gevonden</td></tr>");
else
{
while ($row_user=mysql_fetch_array($rusers))
{
print("<tr>\n");
$avatar = "";
$avatar = ($row_user["avatar"] && $row_user["avatar"] != "" ? htmlspecialchars($row_user["avatar"]) : "");
$userid = $row_user["id"];
$cQuery = mysql_query("SELECT `donations` FROM `donations` WHERE userid=$userid");
if (cQuery)
{
$donatie = mysql_result($cQuery, donations);
}
else
$donatie=0;
$dn = $donatie/100;
if ($dn >= 13)
$d = "images/smilies/thumbsup2.gif";
elseif ($dn >= 6.5)
$d = "images/smilies/grin2.gif";
elseif ($dn >= 3.90)
$d = "images/smilies/smile2.gif";
elseif ($dn >= 2.60)
$d = "images/smilies/noexpression2.gif";
elseif ($dn >= 1.30)
$d = "images/smilies/sad2.gif";
else
$d = "images/smilies/thumbsdown.gif";
$donatie=number_format($dn,2)." <img src=$d>";
if ($dn < $tobed)[/code]
Dit is het script wat Donatie betreft. Met dit ingevuld krijg ik dit als error:
[code]Resource id #77
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mp3start/domains/mp3-start.nl/public_html/torrents/notsponsors.php on line 49[/code]
Vreemd?