The site i am creating just now has a forum and many comments sections, i realized since the code was identical in order to keep them all consistent i could make a basic function that could just be called for so that there would only be one port for bug fixing and design updates.
my problem is that these two lines in the function cause it to stop and i do not know why as it worked fine outside the function.
Here is the full code
my problem is that these two lines in the function cause it to stop and i do not know why as it worked fine outside the function.
PHP:
// The edit button //
if ($usrname == $row["username"] || $session->userlevel == '8' || $session->isAdmin())
{
echo '<span class="button"><a href="edit_comment.php?id='.$row["id"].'">Edit</a></span>';
}
// The delete button //
if ($session->userlevel == '8' || $session->isAdmin())
{
echo '<span class="button"><a href="show_comments.php?id=$id&delete='.$row["id"].'">Delete</a></span>';
}
Here is the full code
PHP:
<?php
function forum_thread($row, $number, $edit_button, $delete_button) {
// Function for displaying a thread //
global $session;
// Begin output of the thread //
// ************************** //
// The container //
echo '<div class="thread_container">';
// Send the date for processing and return it //
$date = date_convert($row['date']);
// End of date processing //
// The header contains the subject, post date and the thread number //
echo ' <div class="thread_title">
<div class="thread_subject">Subject: '.$row["subject"].'
<span class="thread_number">'.$date.'</span></div>
<span class="thread_right">#'.$number.'</span>
</div>';
// Returns ether the users avatar or the no avatar if the user has none
if ($row['avatar'] == '' || $row['avatar'] == 'not entered')
{
}
else
{
$avatar = '<div class="thread_avatar"><img width="110px" src="../images/avatars/'.$row["avatar"].'" alt="'.$row["avatar"].'\'s avatar" /></div>';
}
// The profile and mail me variables //
$mail_me = '<a href="../mail/compose.php?user='.$row['username'].'">
<img src="../images/layout/mail_new.png" alt="mail" height="14px" hspace="5px">
</a>';
$my_profile = '<a href="../user_service/user_profile.php?&user='.$row['username'].'">
<img src="../images/layout/friends.jpg" alt="profile" height="20px">
</a>';
// inner containing element for the thread //
echo '<div class"thread_inner_container">';
// Returns the poster information //
echo '<div class="thread_userstats">';
echo $avatar;
echo '<div class="thread_username">'.$row['username'].'</div>';
echo '<div class="thread_userrank">'.user_rank($row['username']).'</div>';
echo '<div class="thread_usertools">'.$mail_me, $my_profile.'</div>';
echo '</div>';
// The body text of the thread, comment for comments and body for forum topics //
echo '<div class="thread_body">';
if (isset($row["comment"]))
{
$body = $row["comment"];
}
else
{
$body = $row["post"];
}
$quote_start = "\[quote\]";
$string = $body;
$new_string = preg_replace("/".$quote_start."/i", "<div class=\"quote\">", $string);
$stingie = $new_string;
$quote_end = "\[\/quote\]";
$com_string = preg_replace("/".$quote_end."/i", "</div>", $stingie);
if ($com_string == "") {
$com_string = $body;
}
echo stripslashes($com_string);
// The button box //
echo '<div class="thread_button_box">';
// The edit button //
if ($usrname == $row["username"] || $session->userlevel == '8' || $session->isAdmin())
{
echo '<span class="button"><a href="'.$edit_button.'">Edit</a></span>';
}
// The delete button //
if ($session->userlevel == '8' || $session->isAdmin())
{
echo '<span class="button"><a href="'.$delete_button.'">Delete</a></span>';
}
// End of the button box //
echo '</div>';
// End of Thread body //
echo '</div>';
// end of the inner container //
echo '</div>';
// End of container //
echo '</div>';
// End function //
}
?>