een id uit database halen
$query_replys = mysql_query("SELECT * FROM replys WHERE forumid=$forumid");
$replys=mysql_num_rows($query_replys);
if ($replys == 0) {
$thread ="nieuwmap.gif";
$alt ="$replys reacties";
}
if ($replys > $mapwarm) {
$thread ="warm.gif";
$alt ="$replys reacties";
}
if (0 < $replys AND $replys < $mapwarm) {
$thread ="map.gif";
$alt ="$replys reacties";
}
doe niet elke keer if maar doe daar elseif en de $alt elke keer slaat ook nergens op die is toch het zelfde.
De enkele quotes om $forumid .
@tim: heb je al eens gekeken wat voor een error je krijgt?
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
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
<?php
include("connection.php");
verbindt();
echo "<table align=center><center><TR>";
function get_search_query($keywords,$table_name,$sort_column,$search_columns,$search_method) {
$keywords = trim($keywords);
$keywords = ereg_replace ('\+', "", $keywords);
$keywords = ereg_replace ('\-', "", $keywords);
while (ereg(' ',$keywords)) {
$keywords = ereg_replace(' ',' ',$keywords);
}
$keywords = explode(' ',$keywords);
$num_keywords = count($keywords);
$num_searchcolumn = count($search_columns);
$search_method = strtoupper($search_method);
$query = "SELECT * FROM $table_name WHERE ";
for ($i =0; $i < $num_keywords; $i++)
{
if ($i != 0)
$query .= "$search_method ";
$stringWoord = $keywords[$i];
for ($j = 0; $j < $num_searchcolumn; $j++)
{
if ($j == 0)
$query .= "( ";
if ($j != 0)
$query .= "OR ";
$kolom = $search_columns[$j];
$query .= "$kolom LIKE '%$stringWoord%' ";
}
$query .= ") ";
}
$query .= "ORDER BY '$sort_column' ASC";
return $query;
}
$search_columns = array ('naam', 'onderwerp');
if ($_POST['opZoeken']==0)
$search_columns = array('naam');
else if ($_POST['opZoeken']==1)
$search_columns = array('onderwerp');
$keywords= $_POST['zoektermen'];
$table_name='downloads';
$postTypeZoeken = $_POST['optieZoeken'];
$typeZoeken="";
if ($postTypeZoeken == 0)
$typeZoeken = "AND";
else
$typeZoeken = "OR";
$querySearch = get_search_query($keywords,$table_name,'naam',$search_columns,$typeZoeken);
$result = mysql_query($querySearch) or die("Probs query zoeken");
$resultaten = mysql_num_rows($result);
echo "
";
while($row=mysql_fetch_object($result))
{
$row->naam = str_replace("#komma1#","$komma","$row->naam");
$row->onderwerp = str_replace("#komma1#","$komma","$row->onderwerp");
if ($row->filenaam == "Nieuwsberichten")
{
if (strlen($row->naam) > 200)
{
if ($row->onderwerp{199} == " ")
{
$row->onderwerp = substr($row->naam, 0, 50);
} else {
$row->onderwerp = substr($row->naam, 0, 50);
}
$row->onderwerp .= "...";
}
}
echo "";
}
?>
include("connection.php");
verbindt();
echo "<table align=center><center><TR>";
function get_search_query($keywords,$table_name,$sort_column,$search_columns,$search_method) {
$keywords = trim($keywords);
$keywords = ereg_replace ('\+', "", $keywords);
$keywords = ereg_replace ('\-', "", $keywords);
while (ereg(' ',$keywords)) {
$keywords = ereg_replace(' ',' ',$keywords);
}
$keywords = explode(' ',$keywords);
$num_keywords = count($keywords);
$num_searchcolumn = count($search_columns);
$search_method = strtoupper($search_method);
$query = "SELECT * FROM $table_name WHERE ";
for ($i =0; $i < $num_keywords; $i++)
{
if ($i != 0)
$query .= "$search_method ";
$stringWoord = $keywords[$i];
for ($j = 0; $j < $num_searchcolumn; $j++)
{
if ($j == 0)
$query .= "( ";
if ($j != 0)
$query .= "OR ";
$kolom = $search_columns[$j];
$query .= "$kolom LIKE '%$stringWoord%' ";
}
$query .= ") ";
}
$query .= "ORDER BY '$sort_column' ASC";
return $query;
}
$search_columns = array ('naam', 'onderwerp');
if ($_POST['opZoeken']==0)
$search_columns = array('naam');
else if ($_POST['opZoeken']==1)
$search_columns = array('onderwerp');
$keywords= $_POST['zoektermen'];
$table_name='downloads';
$postTypeZoeken = $_POST['optieZoeken'];
$typeZoeken="";
if ($postTypeZoeken == 0)
$typeZoeken = "AND";
else
$typeZoeken = "OR";
$querySearch = get_search_query($keywords,$table_name,'naam',$search_columns,$typeZoeken);
$result = mysql_query($querySearch) or die("Probs query zoeken");
$resultaten = mysql_num_rows($result);
echo "
";
while($row=mysql_fetch_object($result))
{
$row->naam = str_replace("#komma1#","$komma","$row->naam");
$row->onderwerp = str_replace("#komma1#","$komma","$row->onderwerp");
if ($row->filenaam == "Nieuwsberichten")
{
if (strlen($row->naam) > 200)
{
if ($row->onderwerp{199} == " ")
{
$row->onderwerp = substr($row->naam, 0, 50);
} else {
$row->onderwerp = substr($row->naam, 0, 50);
}
$row->onderwerp .= "...";
}
}
echo "";
}
?>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
<?php
$res = mysql_query("SELECT COUNT( 1 ) as aantal FROM replys WHERE forumid=".$forumid);
if (!$res)
{
echo 'Een fout: '.mysql_error();
}
else
{
$result = mysql_fetch_assoc($res);
echo 'het aantal is '.$result['aantal'];
}
?>
$res = mysql_query("SELECT COUNT( 1 ) as aantal FROM replys WHERE forumid=".$forumid);
if (!$res)
{
echo 'Een fout: '.mysql_error();
}
else
{
$result = mysql_fetch_assoc($res);
echo 'het aantal is '.$result['aantal'];
}
?>