Sorry i´m total new to PHP and databses 🙂 Yes I use database to store the al the content i blog.php and I tryd to put in the smileys code in to the blog but it would not work. I think i made it wrong
This is the blog.php code
$q = "SELECT * from blog order by date desc ";
$result= mysql_query($q, $connection) or die
("Could not execute query : $q." . mysql_error());
// dynamic navigation variables
$rows_per_page=5; // adjust the number here to display number of entries per page
$total_records=mysql_num_rows($result);
$pages = ceil($total_records / $rows_per_page);
mysql_free_result($result);
if (!isset($screen))
$screen=0;
$start = $screen * $rows_per_page;
$q .= "LIMIT $start, $rows_per_page";
$result= mysql_query($q, $connection) or die
("Could not execute query : $q." . mysql_error());
while ($row=mysql_fetch_array($result))
{
$id=$row["id"];
$name=$row["name"];
$email=$row["email"];
$entry=$row["entry"];
$date=$row["date"];
$icon=$row["icon"];
$title=$row["title"];
?>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><p class="head"><?php echo "$title"; ?></td>
</tr>
<tr>
<td><p class="content">
<?php echo "$entry"; ?>
<p class="content">Posted by <a href="mailto:<?php echo "$email"; ?>"><b><?php echo "$name"; ?></a></b> on <?php echo "$date"; ?>.</p>
<p align="right">
<?php
$query = "select id from blog_comments where blog_id='$id'";
$ret = mysql_query($query);
$comment_num = mysql_num_rows($ret);
// add comments line here
echo "<a href=\"#\"";
echo " onClick=\"window.open('readcomments.php?id=$id', 'NewPopup', 'toolbar=no, location=no, status=no, scrollbars=yes, menubar=no, titlebar=no, height=600, width=425')\">";
echo "Comment</a> ( $comment_num )";
echo "</p>";
?>
</td>
</tr>
</table>
<br>
<div align="center">
<p>
<?php
}
// Display dynamic navigation here
// create the dynamic links
if ($screen > 0) {
$j = $screen - 1;
$url = "$PHP_SELF?screen=$j";
echo "<a href=\"$url\">Prev</a>";
}
// page numbering links now
for ($i = 0; $i < $pages; $i++) {
$url = "$PHP_SELF?screen=" . $i;
$j = $i + 1;
echo " | <a href=\"$url\">$j</a> | ";
}
if ($screen < $pages-1) {
$j = $screen + 1;
$url = "$PHP_SELF?screen=$j";
echo "<a href=\"$url\">Next</a>";
}
?>
</div>
and if got it right my slimeys code should look something like this?
function text2smilies($input)
{
$output = str_replace(":)","<img src=smilies/happy.gif>",$input);
$output = str_replace(":(","<img src=smilies/sad.gif>",$sout);
RETURN $output;
}