<?php
$server = mysql_connect($host, $username, $password);
$connection = mysql_select_db($database, $server);
$db = mysql_select_db($database, $server);
if (isset($_GET['id']) and is_numeric($_GET['id'])) {
$id = $_GET['id'];
$usrname = $_GET['usrname'];
} else {
exit ('invalid id');
}
$sql = mysql_query("SELECT * FROM storys_comments WHERE story_id = $id ORDER BY id DESC");
$numofrows = mysql_num_rows($sql);
print '<table width="100%" border="0" cellpadding="4" cellspacing="0" >';
print '<tr><td width="60%"></td><td width="30%"></td><td width="10%"></td></tr>';
if(mysql_num_rows($sql)) // we got some results
{
$i = 0;
while($row = mysql_fetch_array($sql))
{
if($i++ % 2)
{
print '<tr class="pink">';
}
else
{
print '<tr class="wight">';
}
//the output//
printf("<td>%s</td><td>%s</td><td>Edit</td>
if ($usrname == $row[1] || $session->isAdmin()) {
echo '| <a href="stories_edit.php?id=' . $id . '">Edit</a>';
}
</tr>", $row["3"], $row["2"]);
}
print '</table>';
}
else
{
print '<p class="error">No, Comments</p>';
}
?>
Okies this is my code you will see right at the bottom i have to if logic witch is ment to display a edit button if the active user is ether a admin or the original poster. Obvisly im to dumb to do this right so i could do with a hand please.