Hulp nodig
Ik heb nu dus een nieuws script in mijn site verwerkt, maar me vraag is of er geen optie is om 1 headline te maken dus als je een nieuwsbericht post dat je kan aanvinken om hem als headline te doen en dan kan je op lees meer klikken en daar kunnen ze de rest lezen en reactie's posten. en dan moeten alle andere berichten gewoon zoals het er nu uitziet.
lijkt me namelijk wel wat mooier ;)
greetz Jeroen
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?
$headline = true;
while($data = mysql_fetch_array($res, MYSQL_ASSOQ))
{
if($headline)
{
# Het eerste bericht
$headline = false;
}
else
{
# De normale layout
}
}
?>
$headline = true;
while($data = mysql_fetch_array($res, MYSQL_ASSOQ))
{
if($headline)
{
# Het eerste bericht
$headline = false;
}
else
{
# De normale layout
}
}
?>
Zoiets? :)
maar dit is dus me nieuws script is een script van deze site, me vraag is moet het hierin of moet het in de admin.php want dit is de nieuws.php.
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?
include("functions.php");
require("database.php");
function maand($counter)
{
if ($counter == 1)
$count = "Januari";
elseif ($counter == 2)
$count = "Februari";
elseif ($counter == 3)
$count = "Maart";
elseif ($counter == 4)
$count = "April";
elseif ($counter == 5)
$count = "Mei";
elseif ($counter == 6)
$count = "Juni";
elseif ($counter == 7)
$count = "Juli";
elseif ($counter == 8)
$count = "Augustus";
elseif ($counter == 9)
$count = "September";
elseif ($counter == 10)
$count = "Oktober";
elseif ($counter == 11)
$count = "November";
elseif ($counter == 12)
$count = "December";
return $count;
}
if (!$HTTP_GET_VARS[id] && !$HTTP_POST_VARS[id])
{
$counter = 1;
while($counter <= 12)
{
if ($counter == 1)
$counter = "0" . $counter;
$sql = "SELECT id,titel,datum,substring(datum, 7, 4) as year FROM nieuws WHERE SUBSTRING(datum, 4, 2) = $counter order by id DESC,year DESC";
$res = mysql_query($sql);
if (mysql_num_rows($res) >= 1)
{
$year = "$row[year]";
$berichten = mysql_num_rows($res);
$month = maand($counter);
if ($berichten == 1)
echo "<b>$month $year</b> ($berichten bericht)";
else
echo "<b>$month $year</b> ($berichten berichten)";
echo "<blockquote>";
while ($row = mysql_fetch_array($res))
{
$sql2 = "select id from reacties where tid = $row[id]";
$res2 = mysql_query($sql2);
$count = mysql_num_rows($res2);
echo "[$row[datum]] <a href=$PHP_SELF?id=$row[id]>$row[titel]</a> ($count)<br>";
}
echo "</blockquote><p>";
}
else
{
if ($counter <= 12)
{
$length = strlen(maand($counter)) - 1;
$month = strtoupper(substr(maand($counter), 0, -$length)) . substr(maand($counter), 1);
if ($counter == 11)
$months .= "$month en ";
elseif ($counter == 12)
$months .= "$month";
else
$months .= "$month" . ", ";
}
if ($counter == 12)
{
if (strlen($months) <= 8)
echo "Er zijn (nog) geen nieuwsberichten van de maand: $months.";
else
echo "Er zijn (nog) geen nieuwsberichten van de maanden: $months.";
}
}
$counter++;
}
}
else
{
if ($HTTP_POST_VARS["submit"] && $HTTP_POST_VARS["naam"] && $HTTP_POST_VARS["msg"])
{
$datum = date("d.m.Y H:i");
$sql = "INSERT INTO reacties (id, naam, titel, msg, datum, ipadres, tid) VALUES ";
$sql .= "('', '$HTTP_POST_VARS[naam]', '$HTTP_POST_VARS[titel]', '$HTTP_POST_VARS[msg]', '$datum', '$REMOTE_ADDR', '$HTTP_GET_VARS[id]')";
$res = mysql_query($sql);
if ($res)
echo "<SCRIPT LANGUAGE=\"javascript\" TYPE=\"text/javascript\">window.location='$PHP_SELF?id=$HTTP_GET_VARS[id]'</SCRIPT>\n";
else
echo "Reactie niet toegevoegd.";
}
else
{
$sql = "SELECT id,titel,msg,datum FROM nieuws WHERE id = '$HTTP_GET_VARS[id]'";
$res = mysql_query($sql);
echo "<a href=\"$PHP_SELF\" target=\"_top\">nieuws overzicht</a><p>";
if (mysql_num_rows($res) >= 1)
{
$row = mysql_fetch_array($res);
$hiddentitel = $row[titel];
echo "<span class=\"kopje\">$row[titel]</span> [$row[datum]]<p>";
$row[msg] = bbcode_do($row[msg]);
$row[msg] = smiles_do($row[msg]);
$row[msg] = nl2br($row[msg]);
echo "$row[msg]<p>";
echo "<hr color=\"#000000\"><p>";
$sql = "SELECT id,naam,titel,msg,datum FROM reacties WHERE tid = '$HTTP_GET_VARS[id]' ORDER BY id DESC";
$res = mysql_query($sql);
echo "<a name=\"reacties\"><table border=\"1\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#CFC9B4\" width=\"100%\"><tr><td>";
echo "<table border=0 cellspacing=0 cellpadding=5 width=\"100%\"></a>";
if (mysql_num_rows($res) >= 1)
{
while ($row = mysql_fetch_array($res))
{
echo "<tr><td bgcolor=\"#E1F3E5\"><b>$row[naam]</b> [$row[datum]]</td></tr>";
$row[msg] = bbcode_do($row[msg]);
$row[msg] = smiles_do($row[msg]);
$row[msg] = nl2br($row[msg]);
echo "<tr><td bgcolor=\"#E1F3E5\">$row[msg]</td></tr>";
}
}
else
{
echo "<tr><td bgcolor=\"#E1F3E5\">Er zijn nog geen reacties op dit bericht</td></tr>";
}
echo "</td></tr></table></table><p>";
echo "<form method=\"post\" action=\"$PHP_SELF?id=$HTTP_GET_VARS[id]\">";
echo "<input type=\"hidden\" name=\"titel\" value=\"$hiddentitel\">";
echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\" bgcolor=\"#E1F3E5\" bordercolor=\"#CFC9B4\" width=\"100%\">";
echo "<tr><td><table border=0 cellspacing=0 cellpadding=0>";
echo "<tr><td width=\"60\" valign=\"top\">Naam</td><td><input type=\"text\" name=\"naam\">";
echo "<tr><td width=\"60\" valign=\"top\">Bericht</td><td><textarea name=\"msg\" rows=\"5\" cols=\"25\"></textarea>";
echo "<tr><td width=\"60\"> </td><td><input type=\"submit\" name=\"submit\" value=\"reactie plaatsen\">";
echo "</table></td></tr>";
echo "</table>";
echo "</form>";
}
else
{
echo "Nieuws bericht niet gevonden.";
}
echo "<p><a href=\"$PHP_SELF\" target=\"_top\">nieuws overzicht</a><p>";
}
}
?>
include("functions.php");
require("database.php");
function maand($counter)
{
if ($counter == 1)
$count = "Januari";
elseif ($counter == 2)
$count = "Februari";
elseif ($counter == 3)
$count = "Maart";
elseif ($counter == 4)
$count = "April";
elseif ($counter == 5)
$count = "Mei";
elseif ($counter == 6)
$count = "Juni";
elseif ($counter == 7)
$count = "Juli";
elseif ($counter == 8)
$count = "Augustus";
elseif ($counter == 9)
$count = "September";
elseif ($counter == 10)
$count = "Oktober";
elseif ($counter == 11)
$count = "November";
elseif ($counter == 12)
$count = "December";
return $count;
}
if (!$HTTP_GET_VARS[id] && !$HTTP_POST_VARS[id])
{
$counter = 1;
while($counter <= 12)
{
if ($counter == 1)
$counter = "0" . $counter;
$sql = "SELECT id,titel,datum,substring(datum, 7, 4) as year FROM nieuws WHERE SUBSTRING(datum, 4, 2) = $counter order by id DESC,year DESC";
$res = mysql_query($sql);
if (mysql_num_rows($res) >= 1)
{
$year = "$row[year]";
$berichten = mysql_num_rows($res);
$month = maand($counter);
if ($berichten == 1)
echo "<b>$month $year</b> ($berichten bericht)";
else
echo "<b>$month $year</b> ($berichten berichten)";
echo "<blockquote>";
while ($row = mysql_fetch_array($res))
{
$sql2 = "select id from reacties where tid = $row[id]";
$res2 = mysql_query($sql2);
$count = mysql_num_rows($res2);
echo "[$row[datum]] <a href=$PHP_SELF?id=$row[id]>$row[titel]</a> ($count)<br>";
}
echo "</blockquote><p>";
}
else
{
if ($counter <= 12)
{
$length = strlen(maand($counter)) - 1;
$month = strtoupper(substr(maand($counter), 0, -$length)) . substr(maand($counter), 1);
if ($counter == 11)
$months .= "$month en ";
elseif ($counter == 12)
$months .= "$month";
else
$months .= "$month" . ", ";
}
if ($counter == 12)
{
if (strlen($months) <= 8)
echo "Er zijn (nog) geen nieuwsberichten van de maand: $months.";
else
echo "Er zijn (nog) geen nieuwsberichten van de maanden: $months.";
}
}
$counter++;
}
}
else
{
if ($HTTP_POST_VARS["submit"] && $HTTP_POST_VARS["naam"] && $HTTP_POST_VARS["msg"])
{
$datum = date("d.m.Y H:i");
$sql = "INSERT INTO reacties (id, naam, titel, msg, datum, ipadres, tid) VALUES ";
$sql .= "('', '$HTTP_POST_VARS[naam]', '$HTTP_POST_VARS[titel]', '$HTTP_POST_VARS[msg]', '$datum', '$REMOTE_ADDR', '$HTTP_GET_VARS[id]')";
$res = mysql_query($sql);
if ($res)
echo "<SCRIPT LANGUAGE=\"javascript\" TYPE=\"text/javascript\">window.location='$PHP_SELF?id=$HTTP_GET_VARS[id]'</SCRIPT>\n";
else
echo "Reactie niet toegevoegd.";
}
else
{
$sql = "SELECT id,titel,msg,datum FROM nieuws WHERE id = '$HTTP_GET_VARS[id]'";
$res = mysql_query($sql);
echo "<a href=\"$PHP_SELF\" target=\"_top\">nieuws overzicht</a><p>";
if (mysql_num_rows($res) >= 1)
{
$row = mysql_fetch_array($res);
$hiddentitel = $row[titel];
echo "<span class=\"kopje\">$row[titel]</span> [$row[datum]]<p>";
$row[msg] = bbcode_do($row[msg]);
$row[msg] = smiles_do($row[msg]);
$row[msg] = nl2br($row[msg]);
echo "$row[msg]<p>";
echo "<hr color=\"#000000\"><p>";
$sql = "SELECT id,naam,titel,msg,datum FROM reacties WHERE tid = '$HTTP_GET_VARS[id]' ORDER BY id DESC";
$res = mysql_query($sql);
echo "<a name=\"reacties\"><table border=\"1\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#CFC9B4\" width=\"100%\"><tr><td>";
echo "<table border=0 cellspacing=0 cellpadding=5 width=\"100%\"></a>";
if (mysql_num_rows($res) >= 1)
{
while ($row = mysql_fetch_array($res))
{
echo "<tr><td bgcolor=\"#E1F3E5\"><b>$row[naam]</b> [$row[datum]]</td></tr>";
$row[msg] = bbcode_do($row[msg]);
$row[msg] = smiles_do($row[msg]);
$row[msg] = nl2br($row[msg]);
echo "<tr><td bgcolor=\"#E1F3E5\">$row[msg]</td></tr>";
}
}
else
{
echo "<tr><td bgcolor=\"#E1F3E5\">Er zijn nog geen reacties op dit bericht</td></tr>";
}
echo "</td></tr></table></table><p>";
echo "<form method=\"post\" action=\"$PHP_SELF?id=$HTTP_GET_VARS[id]\">";
echo "<input type=\"hidden\" name=\"titel\" value=\"$hiddentitel\">";
echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\" bgcolor=\"#E1F3E5\" bordercolor=\"#CFC9B4\" width=\"100%\">";
echo "<tr><td><table border=0 cellspacing=0 cellpadding=0>";
echo "<tr><td width=\"60\" valign=\"top\">Naam</td><td><input type=\"text\" name=\"naam\">";
echo "<tr><td width=\"60\" valign=\"top\">Bericht</td><td><textarea name=\"msg\" rows=\"5\" cols=\"25\"></textarea>";
echo "<tr><td width=\"60\"> </td><td><input type=\"submit\" name=\"submit\" value=\"reactie plaatsen\">";
echo "</table></td></tr>";
echo "</table>";
echo "</form>";
}
else
{
echo "Nieuws bericht niet gevonden.";
}
echo "<p><a href=\"$PHP_SELF\" target=\"_top\">nieuws overzicht</a><p>";
}
}
?>
$HTTP_POST_VARS[] -> $_POST[];
$HTTP_GET_VARS[] -> $_GET[];
$PHP_SELF -> $_SERVER['PHP_SELF'];
En dit : $row[msg] moet zijn $row['msg'];
Met '' dus, en dat bij alle arrayindexes ...
zou je in bovenstaande script is al die dingen kunnen wijzigen zodat ik hem kan gebruiken want ik krijg elke keer die rot errors ;(
alvast bedankt,
jeroen