Zoeken in meerdere tabellen.
Nu komt mijn probleem: als je nu bijvoorbeeld intypt 'zwartboek dvdrip' dan vindtie niks omdat die tabellen niet zijn gecombineerd. Wat moet ik in het onderstaande script veranderen om te zorgen dat de tabellen gecombineerd worden?
Alvast hartelijke dank.
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
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
<?php
// Get the search variable from URL
$var = @$_GET['q'] ;
$trimmed = trim($var); //trim whitespace from the stored variable
// rows to return
$limit=10;
// check for an empty string and display a message.
if ($trimmed == "")
{
exit;
}
// check for a search parameter
if (!isset($var))
{
exit;
}
//connect to your database ** EDIT REQUIRED HERE **
mysql_connect("","",""); //(host, username, password)
//specify database ** EDIT REQUIRED HERE **
mysql_select_db("") or die("Unable to select database"); //select which database we're using
// Build SQL Query
$query = "select * from downloadsysteem where url_van_download like \"%$trimmed%\"
order by type DESC"; // EDIT HERE and specify your table and field names for the SQL query
$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);
// If we have no results, offer a google search as an alternative
if ($numrows == 0)
{
echo "<h4>Zoekresultaten</h4>";
echo "<p>Sorry, geen resultaten gevonden voor: "" . $trimmed . ""</p>";
// google
echo "<p><font color=#9BEB22><a href=\"http://www.huiswerksite.com/verzoekjes.php\">Klik hier</font></a> om je wens bij verzoekjes toe te voegen.</p>";
}
// next determine if s has been passed to script, if not use 0
if (empty($s)) {
$s=0;
}
// get results
$query .= " limit $s,$limit";
$result = mysql_query($query) or die("Couldn't execute query");
$sql = mysql_query($query);
$numofrows = mysql_num_rows($result);
// display what the person searched for
// begin to show results set
echo "<TABLE BORDER=\"0\" cellpadding=\"3\" cellspacing=\"0\" width=\"760\">\n";
echo "<TR bgcolor=\"white\"><TD width=\"350\"><font face= verdana><font color=#9BEB22><font size=\"1\">Titel</TD><TD width=\"200\"><font face= verdana><font color=#9BEB22><font size=\"1\">Vak</TD><TD width=\"100\"><font face= verdana><font color=#9BEB22><font size=\"1\">Type</TD><TD width=\"100\"><font face= verdana><font color=#9BEB22><font size=\"1\">Toegevoegd</TD><TD width=\"100\"><font face= verdana><font color=#9BEB22><font size=\"1\">Woorden</TD><TD width=\"100\"><font face= verdana><font color=#9BEB22><font size=\"1\">Niveau</font></TD></TR>\n";
for($i = 0; $i < $numofrows; $i++) {
$row = mysql_fetch_array($sql); //get a row from our result set
if($i % 2) { //this means if there is a remainder
echo "<TR bgcolor=\"white\">\n";
} else { //if there isn't a remainder we will do the else
echo "<TR bgcolor=\"#F5F5F5\">\n";
}
echo "<TD color=\"#585858\"><font color=#585858><font face=Verdana><font size=\"1\">".$row['url_van_download']."<font color=#585858><TD color=\"#585858\"><font color=#585858><font face=Verdana><font size=\"1\">".$row['genre']."</TD><TD color=\"#585858\"><font color=#585858><font face=Verdana><font size=\"1\">".$row['grootte']."</TD><TD color=\"#585858\"><font color=#585858><font face=Verdana><font size=\"1\">".$row['Toegevoegd']."</TD><TD color=\"#585858\"><font color=#585858><font face=Verdana><font size=\"1\">".$row['type']."</TD><TD color=\"#585858\"><font color=#585858><font face=Verdana><font size=\"1\">".$row['Allmovie_com_rating']."</TD>\n";
echo "</TR>\n";
}
$currPage = (($s/$limit) + 1);
// next we need to do the links to other results
if ($s>=1) { // bypass PREV link if s is 0
$prevs=($s-$limit);
print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><<
Prev 10</a>  ";
}
// calculate number of pages needing links
$pages=intval($numrows/$limit);
// $pages now contains int of pages needed unless there is a remainder from division
if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}
// check to see if last page
if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {
// not last page so give NEXT link
$news=$s+$limit;
}
$a = $s + ($limit) ;
if ($a > $numrows) { $a = $numrows ; }
$b = $s + 1 ;
?>
// Get the search variable from URL
$var = @$_GET['q'] ;
$trimmed = trim($var); //trim whitespace from the stored variable
// rows to return
$limit=10;
// check for an empty string and display a message.
if ($trimmed == "")
{
exit;
}
// check for a search parameter
if (!isset($var))
{
exit;
}
//connect to your database ** EDIT REQUIRED HERE **
mysql_connect("","",""); //(host, username, password)
//specify database ** EDIT REQUIRED HERE **
mysql_select_db("") or die("Unable to select database"); //select which database we're using
// Build SQL Query
$query = "select * from downloadsysteem where url_van_download like \"%$trimmed%\"
order by type DESC"; // EDIT HERE and specify your table and field names for the SQL query
$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);
// If we have no results, offer a google search as an alternative
if ($numrows == 0)
{
echo "<h4>Zoekresultaten</h4>";
echo "<p>Sorry, geen resultaten gevonden voor: "" . $trimmed . ""</p>";
echo "<p><font color=#9BEB22><a href=\"http://www.huiswerksite.com/verzoekjes.php\">Klik hier</font></a> om je wens bij verzoekjes toe te voegen.</p>";
}
// next determine if s has been passed to script, if not use 0
if (empty($s)) {
$s=0;
}
// get results
$query .= " limit $s,$limit";
$result = mysql_query($query) or die("Couldn't execute query");
$sql = mysql_query($query);
$numofrows = mysql_num_rows($result);
// display what the person searched for
// begin to show results set
echo "<TABLE BORDER=\"0\" cellpadding=\"3\" cellspacing=\"0\" width=\"760\">\n";
echo "<TR bgcolor=\"white\"><TD width=\"350\"><font face= verdana><font color=#9BEB22><font size=\"1\">Titel</TD><TD width=\"200\"><font face= verdana><font color=#9BEB22><font size=\"1\">Vak</TD><TD width=\"100\"><font face= verdana><font color=#9BEB22><font size=\"1\">Type</TD><TD width=\"100\"><font face= verdana><font color=#9BEB22><font size=\"1\">Toegevoegd</TD><TD width=\"100\"><font face= verdana><font color=#9BEB22><font size=\"1\">Woorden</TD><TD width=\"100\"><font face= verdana><font color=#9BEB22><font size=\"1\">Niveau</font></TD></TR>\n";
for($i = 0; $i < $numofrows; $i++) {
$row = mysql_fetch_array($sql); //get a row from our result set
if($i % 2) { //this means if there is a remainder
echo "<TR bgcolor=\"white\">\n";
} else { //if there isn't a remainder we will do the else
echo "<TR bgcolor=\"#F5F5F5\">\n";
}
echo "<TD color=\"#585858\"><font color=#585858><font face=Verdana><font size=\"1\">".$row['url_van_download']."<font color=#585858><TD color=\"#585858\"><font color=#585858><font face=Verdana><font size=\"1\">".$row['genre']."</TD><TD color=\"#585858\"><font color=#585858><font face=Verdana><font size=\"1\">".$row['grootte']."</TD><TD color=\"#585858\"><font color=#585858><font face=Verdana><font size=\"1\">".$row['Toegevoegd']."</TD><TD color=\"#585858\"><font color=#585858><font face=Verdana><font size=\"1\">".$row['type']."</TD><TD color=\"#585858\"><font color=#585858><font face=Verdana><font size=\"1\">".$row['Allmovie_com_rating']."</TD>\n";
echo "</TR>\n";
}
$currPage = (($s/$limit) + 1);
// next we need to do the links to other results
if ($s>=1) { // bypass PREV link if s is 0
$prevs=($s-$limit);
print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><<
Prev 10</a>  ";
}
// calculate number of pages needing links
$pages=intval($numrows/$limit);
// $pages now contains int of pages needed unless there is a remainder from division
if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}
// check to see if last page
if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {
// not last page so give NEXT link
$news=$s+$limit;
}
$a = $s + ($limit) ;
if ($a > $numrows) { $a = $numrows ; }
$b = $s + 1 ;
?>