Headline maken in nieuwsscript
ik had al een vraag hierover bij het aanvragen van een script gepost maar ik kan het beter hier kwijt,
ik heb hier van deze site een nieuwspost script vandaan gehaald die werkt overigens perfect.
maar ik zou graag willen dat je de mogelijkheid hebt om een headline te maken dus je als je een nieuwspost maakt dat je aan kan vinken om die nieuwspost als headline te doen.
En dan de rest van de post gewoon zoals het er nu uitziet je kan het zien op
http://members.lycos.co.uk/mannie1500/
die headline moet dan ook een beetje mooi passen in de lay out van de site.
ik hoop dat dit mogelijk is, maar ik zou niet weten in welk script je iets zou moeten aanpassen ik heb een nieuws.php en een admin.php het lijkt me in 1 van die 2.
hieronder staat de nieuws.php en de admin.php
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>";
}
}
?>
Admin.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
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
<?
require("../database.php");
echo "<script language=\"JavaScript\">\n";
echo "function askConfirm(txt,url) {\n";
echo "if (confirm(txt) == true) {\n";
echo "document.location=url\n";
echo "return true;\n";
echo "} \n";
echo "}\n";
echo "</script>";
//-- navigatie
echo "<p><a href=\"$PHP_SELF?show=add\">bericht toevoegen</a> | <a href=\"$PHP_SELF\">overzicht berichten</a></p>";
//-- toevoegen
if ($HTTP_GET_VARS[show] == "add" || $HTTP_POST_VARS[show] == "add")
{
if ($HTTP_POST_VARS["titel"] && $HTTP_POST_VARS["msg"] && $HTTP_POST_VARS["datum"])
{
$sql = "INSERT INTO nieuws (id, titel, msg, datum) VALUES ('', '$HTTP_POST_VARS[titel]', '$HTTP_POST_VARS[msg]', '$HTTP_POST_VARS[datum]')";
$res = mysql_query($sql);
if ($res)
{
echo "Het bericht is toegevoegd aan de site.";
}
else
{
echo "Het bericht is nie toegevoegd aan de site";
}
}
else
{
if ($HTTP_POST_VARS["submit"])
$err = "Enkele velden vergeten.";
if ($HTTP_POST_VARS["datum"])
$cdate = $HTTP_POST_VARS["datum"];
else
$cdate = date("d.m.Y");
echo "<p>Plaats een nieuw bericht</p>";
echo "<form method=\"post\" action=\"$PHP_SELF\">";
echo "<input type=\"hidden\" name=\"show\" value=\"add\">";
echo "Datum: <input type=\"text\" size=\"10\" maxlength=\"10\" value=\"$cdate\" name=\"datum\"><br>";
echo "Titel: <input type=\"text\" size=\"30\" name=\"titel\" value=\"$HTPT_POST_VARS[titel]\"><br>";
echo "Bericht:<br>";
echo "<textarea name=\"msg\" rows=\"6\" cols=\"35\">$HTTP_POST_VARS[msg]</textarea><br>";
echo "<input type=\"submit\" name=\"submit\" value=\"toevoegen\">";
echo "</form>";
}
}
//-- verwijderen
elseif ($HTTP_GET_VARS["show"] == "del")
{
if (is_numeric($HTTP_GET_VARS["id"]))
{
$sql = "DELETE FROM nieuws WHERE id = $HTTP_GET_VARS[id]";
$res = mysql_query($sql);
if ($res)
{
echo "Bericht verwijderd.";
}
else
{
echo "Bericht is niet verwijderd.";
}
}
else
{
echo "Geen geldig id";
}
}
//-- overzicht
else
{
$sql = "SELECT id,titel FROM nieuws ORDER BY id DESC";
$res = mysql_query($sql);
echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\">";
echo "<tr><td width=\"300\"><b>Titel</b></td><td><b>Wissen</b></td></tr>";
while ($row = mysql_fetch_array($res))
{
echo "<tr><td>$row[titel]</td><td><a href=\"javascript:askConfirm('Wilt u $row[titel] verwijderen?','$PHP_SELF?show=del&id=$row[id]');\">wis</a></td></tr>";
}
echo "</table>";
}
?>
require("../database.php");
echo "<script language=\"JavaScript\">\n";
echo "function askConfirm(txt,url) {\n";
echo "if (confirm(txt) == true) {\n";
echo "document.location=url\n";
echo "return true;\n";
echo "} \n";
echo "}\n";
echo "</script>";
//-- navigatie
echo "<p><a href=\"$PHP_SELF?show=add\">bericht toevoegen</a> | <a href=\"$PHP_SELF\">overzicht berichten</a></p>";
//-- toevoegen
if ($HTTP_GET_VARS[show] == "add" || $HTTP_POST_VARS[show] == "add")
{
if ($HTTP_POST_VARS["titel"] && $HTTP_POST_VARS["msg"] && $HTTP_POST_VARS["datum"])
{
$sql = "INSERT INTO nieuws (id, titel, msg, datum) VALUES ('', '$HTTP_POST_VARS[titel]', '$HTTP_POST_VARS[msg]', '$HTTP_POST_VARS[datum]')";
$res = mysql_query($sql);
if ($res)
{
echo "Het bericht is toegevoegd aan de site.";
}
else
{
echo "Het bericht is nie toegevoegd aan de site";
}
}
else
{
if ($HTTP_POST_VARS["submit"])
$err = "Enkele velden vergeten.";
if ($HTTP_POST_VARS["datum"])
$cdate = $HTTP_POST_VARS["datum"];
else
$cdate = date("d.m.Y");
echo "<p>Plaats een nieuw bericht</p>";
echo "<form method=\"post\" action=\"$PHP_SELF\">";
echo "<input type=\"hidden\" name=\"show\" value=\"add\">";
echo "Datum: <input type=\"text\" size=\"10\" maxlength=\"10\" value=\"$cdate\" name=\"datum\"><br>";
echo "Titel: <input type=\"text\" size=\"30\" name=\"titel\" value=\"$HTPT_POST_VARS[titel]\"><br>";
echo "Bericht:<br>";
echo "<textarea name=\"msg\" rows=\"6\" cols=\"35\">$HTTP_POST_VARS[msg]</textarea><br>";
echo "<input type=\"submit\" name=\"submit\" value=\"toevoegen\">";
echo "</form>";
}
}
//-- verwijderen
elseif ($HTTP_GET_VARS["show"] == "del")
{
if (is_numeric($HTTP_GET_VARS["id"]))
{
$sql = "DELETE FROM nieuws WHERE id = $HTTP_GET_VARS[id]";
$res = mysql_query($sql);
if ($res)
{
echo "Bericht verwijderd.";
}
else
{
echo "Bericht is niet verwijderd.";
}
}
else
{
echo "Geen geldig id";
}
}
//-- overzicht
else
{
$sql = "SELECT id,titel FROM nieuws ORDER BY id DESC";
$res = mysql_query($sql);
echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\">";
echo "<tr><td width=\"300\"><b>Titel</b></td><td><b>Wissen</b></td></tr>";
while ($row = mysql_fetch_array($res))
{
echo "<tr><td>$row[titel]</td><td><a href=\"javascript:askConfirm('Wilt u $row[titel] verwijderen?','$PHP_SELF?show=del&id=$row[id]');\">wis</a></td></tr>";
}
echo "</table>";
}
?>
$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 ...
dit was het antwoord van mitch maar ik heb alles geprobeerd maar krijg steeds parse error of andere errors.
En waarom een nieuw topic?
Als het nodig is zet een admin of modjuh hem wel over ...