hi,
I've made this script:
if (!$kysely = mysql_query("select id,paivays,otsikko,teksti,nimi from kommentti"))
{
// query failed
print "<LI>Haku epäonnistui!";
}
else
{
// query success
if (!$kommentti=mysql_fetch_row($kysely)) print "no comments";
else {
while ($kommentti = mysql_fetch_row($kysely))
{
$paivays=$kommentti[1];
$vuosi=substr($paivays, 0, 4);
$kuukausi=substr($paivays, 6, 2);
$paiva=substr($paivays, 4, 2);
$tunti=substr($paivays, 8, 2);
$minuutti=substr($paivays, 10, 2);
$lukema= $kuukausi."-".$paiva."-".$vuosi." ".$tunti.":".$minuutti;
print "<table width='527' border='0' cellspacing='0' cellpadding='4' class='boksi'>";
print "<tr bgcolor='#99CC99'><td height='20' width='369' class='kysely'>" . htmlentities($kommentti[2]) . "</td>";
print "<td colspan='2' height='20' class='kysely'>" . $lukema . "</td>";
print "</tr><tr><td colspan='3' class='kysely'>" . htmlentities($kommentti[3]) . "</td>";
print "</tr><tr><td colspan='3' class='kysely'>" . htmlentities($kommentti[4]) . "</td>";
print "</tr><tr bgcolor='#99CC99'><td height='20' colspan='3'></td>";
print "</tr></table>";
print "<br>";
}
}
}
Sorry about the variables (in Finnish). Anyhow, this script is supposed to fetch comments from MYSQL database (with a topic title, text, date and writer's name) unless the table is empty, in which case it is supposed to print 'no comments'
It works well enough, except that the first comment doesn't print: only the second and subsequent comments show. I am guessing that the problem lies with the while statement but since I am a hopless newbie, can't really tell what's wrong.
Any help would be appreciated!
Juha