I have a month problem
Posted: Fri Oct 13, 2006 4:56 am
Goodmorning (at leaast... here in the Netherlands it is
)
About a month ago ive took an php script from a dutch site. This included a news system with a react option. If works fine, i could edit it the way i wanted and ive even added some extra data. The only problem is that it puts the months in the wrong order. So the newest month is not on top, bot al the way on the bottom.
Now my knowledge about PHP is very, very bad. So could any1 plzzz help me out?
this is the code:
If u just could edit it, so it should work, or tell me step by step what i should do to fix this (and then i mean really step by step
).
I would be very greatfull!
thnx you very much, and greetz from holland
btw excuse me for my bad english... if it is
About a month ago ive took an php script from a dutch site. This included a news system with a react option. If works fine, i could edit it the way i wanted and ive even added some extra data. The only problem is that it puts the months in the wrong order. So the newest month is not on top, bot al the way on the bottom.
Now my knowledge about PHP is very, very bad. So could any1 plzzz help me out?
this is the code:
Code: Select all
<?
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 ==
$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 (!$_GET['id'] && !$_POST['id'])
{
$counter = 1;
while($counter <= 12)
{
if ($counter == 1)
$counter = "0" . $counter;
$sql = "SELECT id,titel,msg,tijd,afb,datum,substring(datum, 7, 4) as year FROM vb_nieuws WHERE SUBSTRING(datum, 4, 2) = " . $counter . " order by id DESC,year ASC ";
$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 "<span class=maand>" . ucfirst($month) . " " . $year . "</span><span class=reactie-link> (" . $berichten . " bericht)</span>";
else
echo "<span class=maand>" . ucfirst($month) . " " . $year . "</span> <span class=reactie-link>(" . $berichten . " berichten)</span>";
echo "<br /><br><table width=100% cellpadding=2 border=0>";
while ($row = mysql_fetch_array($res))
{
$sql2 = "select id from vb_reacties where tid = " . $row['id'];
$res2 = mysql_query($sql2);
$count = mysql_num_rows($res2);
echo "<tr><td colspan=3><span class=bodytxt><strong> " . htmlentities($row['titel']) . "</strong></span><br><span class=reactie-link>[" . $row['datum'] . "] [" . $row['tijd'] . "]</span><br><br></td></tr>
<tr><td></td><td colspan=3 valign=top><span class=bodytxt><img hspace=5 vspace=5 align=left src=" . $row['afb'] . " />" . nl2br($row['msg']) . "<br><br></span></td></tr>";
echo "<tr><td align=right colspan=4><span align=right class=reactie-link ><br>(aantal reacties:" . $count . ") <span class=class=reactie-link><a class=reactie-link href=" . $_SERVER['PHP_SELF'] . "?id=" . $row['id'] . ">Plaats een reactie >></a></span></span><br><br></td></tr>";
}
echo "</table><br /><br /><br />";
}
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) <=
echo "<span class=datum>Er zijn (nog) geen nieuwsberichten van de maand: " . $months;
else
echo "<span class=datum>Er zijn (nog) geen nieuwsberichten van de maanden: " . $months;
}
}
$counter++;
}
}
else
{
if ($_POST['submit'] && $_POST['naam'] && $_POST['msg'])
{
$datum = date("d.m.Y H:i");
$sql = "INSERT INTO vb_reacties (id, naam, titel, msg, datum, ipadres, tid) VALUES ";
$sql .= "('', '" . $_POST['naam'] . "', '" . $_POST['titel'] . "', '" . $_POST['msg'] . "', '" . $datum . "', '" . $_SERVER['REMOTE_ADDR'] . "', '" . $_GET['id'] . "')";
$res = mysql_query($sql);
if ($res)
echo "<SCRIPT LANGUAGE=\"javascript\" TYPE=\"text/javascript\">window.location='" . $_SERVER['PHP_SELF'] . "?id=" . $_GET['id'] . "'</SCRIPT>\n";
else
echo "Reactie niet toegevoegd.";
}
else
{
//selecteert id, titel, message en datum van vb_nieuws (waar id = waar je geklikt heb)
$sql = "SELECT id,titel,msg,datum,afb,tijd FROM vb_nieuws WHERE id = '" . $_GET['id'] . "'";
// voert uit mysql_query($sql) het bovenste dus
$res = mysql_query($sql);
echo "<a class=reactie-link href=\"" . $_SERVER['PHP_SELF'] . "\" target=\"_top\">Terug naar nieuws overzicht</a><p>";
if (mysql_num_rows($res) >= 1)
{
//voert uit mysql_fetch_array($res) zie stukje hierboven
$row = mysql_fetch_array($res);
$hiddentitel = $row['titel'];
echo "<table width=100%><tr><td colspan=2>";
echo "<span class=bodytxt><strong>" . htmlentities($row['titel']) . "</strong></span><br><span class=reactie-link>[" . $row['datum'] . "] [" . $row['tijd'] . "]</span><p>";
//laat het bericht zie,
$row['msg'] = nl2br($row['msg']);
echo "<table cellspacing=0 border=0><tr><td><img hspace=5 vspace=5 align=left src=" . $row['afb'] . " /><span class=bodytxt>" . $row['msg'] . "</span></td></tr></table><p>";
echo "<hr /><p>";
$sql = "SELECT id,naam,titel,msg,datum FROM vb_reacties WHERE tid = '" . $_GET['id'] . "' ORDER BY id DESC";
$res = mysql_query($sql);
echo "<a name=\"reacties\"><table border=\"0\" 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=\"white\"><span class=bodytxt><strong>" . htmlentities($row['naam']) . "</strong> [" . $row['datum'] . "]</span></td></tr>";
$row['msg'] = nl2br(htmlentities($row['msg']));
echo "<tr><td bgcolor=\"white\"><span class=bodytxt>" . $row['msg'] . "<hr></span></td></tr>";
}
}
else
{
echo "<tr><td bgcolor=\"white\"><span class=reactie-link>Er zijn nog geen reacties op dit bericht</span></td></tr>";
}
echo "</td></tr></table></table><p>";
echo "<form method=\"post\" action=\"$PHP_SELF?id=$_GET[id]\">";
echo "<input type=\"hidden\" name=\"titel\" value=\"$hiddentitel\">";
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\" bgcolor=\"white\" bordercolor=\"white\" width=\"100%\">";
echo "<tr><td><table border=0 cellspacing=0 cellpadding=0>";
echo "<tr><td width=\"60\" valign=\"top\"><span class=bodytxt><strong>Naam</strong></span></strong></td><td><input class=text-field type=\"text\" name=\"naam\">";
echo "<tr><td width=\"60\" valign=\"top\"><span class=bodytxt><strong>Bericht</strong></span></td><td><textarea class=text-field name=\"msg\" rows=\"6\" cols=\"50\"></textarea>";
echo "<tr><td width=\"60\"> </td><td><input class=text-field type=\"submit\" name=\"submit\" value=\"reactie plaatsen\">";
echo "</table></td></tr>";
echo "</table>";
echo "</form>";
}
else
{
echo "Nieuws bericht niet gevonden.";
}
echo "</td></tr></table>";
echo "<br><a class=reactie-link href=\"" . $_SERVER['PHP_SELF'] . "\" target=\"_top\">Terug naar nieuws overzicht</a><p>";
}
}
?>If u just could edit it, so it should work, or tell me step by step what i should do to fix this (and then i mean really step by step
I would be very greatfull!
thnx you very much, and greetz from holland
btw excuse me for my bad english... if it is