[PHP] Announcments

Code:

<?
session_start();
$username=$_SESSION['username'];

include_once("includes/func.php");
include_once("includes/db.php");
logincheck();

?>
<?php
$mysql2=mysql_fetch_object(mysql_query("SELECT * FROM forum_question"));
$mysql=mysql_fetch_object(mysql_query("SELECT * FROM forum_user WHERE username='$username'"));
$mod="$mysql->userlevel";
$sql="SELECT * FROM forum_question WHERE type != '1' ORDER BY lastreply ASC";
// OREDER BY id DESC is order result by descending
$result=mysql_query($sql);
$sqla="SELECT * FROM forum_question WHERE type = '1' ORDER BY id ASC";
$resulta=mysql_query($sqla);
?>
<?
//delete stuff
if($_GET[delete]) {
if($mod == "0") { die('You cannot delete this topic'); }
$delete = $_GET[delete];
$cc=mysql_num_rows(mysql_query("SELECT * FROM forum_question WHERE username='$username' AND id='$delete'"));
if($mod == 1){
mysql_query("DELETE FROM forum_question WHERE id='$delete'");
mysql_query("DELETE FROM forum_answer WHERE question_id='$delete'");
}
echo "Topic Deleted.";
echo "<META HTTP-EQUIV='Refresh' CONTENT='1; URL=index.php'>";
}

//announce stuff
if($_GET[ann]) {
if($mod == "0") { die('You cannot delete this topic'); }
$ann = $_GET[ann];
$cc=mysql_num_rows(mysql_query("SELECT * FROM forum_question WHERE username='$username' AND id='$ann'"));
if($mod == 1){
mysql_query("UPDATE forum_question SET type ='1' WHERE id='$ann'");
}
echo "Topic Announced.";
echo "<META HTTP-EQUIV='Refresh' CONTENT='1; URL=index.php'>";
}

//unannounce stuff
if($_GET[uann]) {
if($mod == "0") { die('You cannot delete this topic'); }
$uann = $_GET[uann];
$cc=mysql_num_rows(mysql_query("SELECT * FROM forum_question WHERE username='$username' AND id='$uann'"));
if($mod == 1){
mysql_query("UPDATE forum_question SET type ='0' WHERE id='$uann'");
}
echo "Topic Un Announced.";
echo "<META HTTP-EQUIV='Refresh' CONTENT='1; URL=index.php'>";
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href=<?php echo '$css/includes/css.css' ?> rel='stylesheet' type='text/css' />

<title>Untitled Document</title>
</head>
<body>
<table width="45%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td width="15%" align="center" bgcolor="#E6E6E6"><strong><a href=index.php>Home</a></strong></td>
<td width="15%" align="center" bgcolor="#E6E6E6"><strong><a href=login.php?logout=yes>Logout</a></strong></td>
<?php
if ($mysql->userlevel == "1"){
?>
<td width="15%" align="center" bgcolor="#E6E6E6"><strong>AdminCP</strong></td>

<?
}
?>
</tr>
</table><br><br>
<? //Announcments
$ca = mysql_query("SELECT * FROM forum_question WHERE type = '0'");
$num_rows = mysql_num_rows($ca);
if ($num_rows == 0){
echo "";
}else{
 ?>
<table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td width="40%" align="center" bgcolor="#E6E6E6"><strong>Announcement</strong></td>
<td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td>
<td width="15%" align="center" bgcolor="#E6E6E6"><strong>Replies</strong></td>
<td width="15%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td>
<?php
if ($mysql->userlevel == "1"){
?>
<td width="5%" align="center" bgcolor="#E6E6E6"><strong>Delete</strong></td>
<td width="5%" align="center" bgcolor="#E6E6E6"><strong>Un announce</strong></td>
<?
}
?>
</tr>

<?php
while($rowsa=mysql_fetch_array($resulta)){ // Start looping table row
?>
<tr>
<td bgcolor="#FFFFFF">
<a href="vtopic.php?id=<? echo $rows['id']; ?>"><? echo $rowsa['topic']; ?></a><BR></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rowsa['view']; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rowsa['reply']; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rowsa['datetime']; ?></td>
<?php
if ($mysql->userlevel == "1"){
?>
<td align="center" bgcolor="#FFFFFF"><strong> <a href="?delete=<? echo $rowsa['id']; ?>"> <img src="images/cross.png" border="0" /></a></strong></td>
<td align="center" bgcolor="#FFFFFF"><strong> <a href="?uann=<? echo $rowsa['id']; ?>"> <img src="images/cross.png" border="0" /></a></strong></td>
<?
}}
?>
</tr>

<tr>
<td colspan="6" align="right" bgcolor="#E6E6E6"><a href="natopic.php"><img src="images/newthread.png" border="0" /></a></td>
</tr>
</table>
<? } //end announcment ?>
<table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td width="40%" align="center" bgcolor="#E6E6E6"><strong>Topic</strong></td>
<td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td>
<td width="15%" align="center" bgcolor="#E6E6E6"><strong>Replies</strong></td>
<td width="15%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td>
<?php
if ($mysql->userlevel == "1"){
?>
<td width="5%" align="center" bgcolor="#E6E6E6"><strong>Delete</strong></td>
<td width="5%" align="center" bgcolor="#E6E6E6"><strong>Announce</strong></td>
<?
}
?>
</tr>

<?php
while($rows=mysql_fetch_array($result)){ // Start looping table row
?>
<tr>
<td bgcolor="#FFFFFF">
<a href="vtopic.php?id=<? echo $rows['id']; ?>"><? echo $rows['topic']; ?></a><BR></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['view']; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['reply']; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td>
<?php
if ($mysql->userlevel == "1"){
?>
<td align="center" bgcolor="#FFFFFF"><strong> <a href="?delete=<? echo $rows['id']; ?>"> <img src="images/cross.png" border="0" /></a></strong></td>
<td align="center" bgcolor="#FFFFFF"><strong> <a href="?ann=<? echo $rows['id']; ?>"> <img src="images/cross.png" border="0" /></a></strong></td>
<?
}}
?>
</tr>

<tr>
<td colspan="6" align="right" bgcolor="#E6E6E6"><a href="ntopic.php"><img src="images/newthread.png" border="0" /></a></td>
</tr>
</table>
</body>
</html>


I dont want the announcement to show if there is no type = ’1′ could anyone help?

View Complete Thread with Replies

No Reply.
Find related on my parent xResources.

Looking for something else? Search for it...

No Replies

There are still no reply for this post.

Leave your reply...

If you want to leave your reply for this post, simply fill out the next form:




You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> .


Powered by: Wordpress & 3G Creations