R.Noon
09-26-2005, 10:36 AM
Alright, I'm having some more problems with this announcements page;
I have a database set up, basically the only table in it I'm dealing with here is my `post` table.
The problem I'm reaching is that despite all of this code that LOOKS like it should work, it isn't.
It's viewing announcements when I ask it to; as it should well do, but it's not viewing announcements from the correct subject.
For instance -- My table has three posts in it, one for each subject.
When I choose a subject; and hit "view" it goes to the page; like it's working, but it views the wrong announcement, and it views the same announcement twice.
Upon closer inspection of my database, I find that the announcement it is viewing is the first on the list.
TIA of course :)
~Ryan
<?php
include('header.php');
$sql= "SELECT * FROM `post`";
$results=mysql_query($sql);
$row=@mysql_fetch_array($results)
?>
<?php
if (!isset($_POST['subj']))
{?>
<form method="post">
<dl align="center">~!~ Subject Of Announcement ~!~
<dd>Web Design<input type="radio" name="subj" value="Web Design"></dd>
<dd>Tech Support<input type="radio" name="subj" value="Tech Support"></dd>
<dd>Site Updates<input type="radio" name="subj" value="Site Updates"></dd>
<dd>All<input type="radio" name="subj" value="All"></dd>
</dl>
<input type="submit" value="View">
</form>
<?php }
if (isset($_POST['subj']))
{ $viewSub = $_POST['subj'];
if ($viewSub != "All")
{
$query = "SELECT * FROM `post` WHERE `$viewSub` = '{$row['subject']}'";
$result2 = mysql_query($query);
while($row2 = mysql_fetch_array($result2)){$posted = $row2[0]; }
}
else $posted = $row['post'];
}
//---------------------//
if (isset($viewSub))
{
if($username!=NULL){ ?><br><div align="left"><b><a href="addannouncement.php">Add An Announcement</a></b></div><br><? }?>
<table border="3">
<tr>
<?php if($username!=NULL){ ?><td align="center"><b>Options</b></td> <?php }?>
<td align="center"><b>Date</b></td>
<td align="center"><b>Anoucement</b></td>
<td align="center"><b>Posted By</b></td>
</tr>
<?php while($row=mysql_fetch_array($results))
{?>
<tr>
<?php if($username!=NULL){ ?><td><?php include('adminedit.php'); ?></td> <?php }?>
<td><?php echo date("d/m/y", $row{'date'}); ?></td>
<td valign="top"><?php echo $posted ?></td>
<td align="center" valign="middle"><?php echo $row{'username'}; ?></td>
</tr>
<?php
}
?>
</table>
<?php } ?>
<?php include('footer.php'); ?>
I have a database set up, basically the only table in it I'm dealing with here is my `post` table.
The problem I'm reaching is that despite all of this code that LOOKS like it should work, it isn't.
It's viewing announcements when I ask it to; as it should well do, but it's not viewing announcements from the correct subject.
For instance -- My table has three posts in it, one for each subject.
When I choose a subject; and hit "view" it goes to the page; like it's working, but it views the wrong announcement, and it views the same announcement twice.
Upon closer inspection of my database, I find that the announcement it is viewing is the first on the list.
TIA of course :)
~Ryan
<?php
include('header.php');
$sql= "SELECT * FROM `post`";
$results=mysql_query($sql);
$row=@mysql_fetch_array($results)
?>
<?php
if (!isset($_POST['subj']))
{?>
<form method="post">
<dl align="center">~!~ Subject Of Announcement ~!~
<dd>Web Design<input type="radio" name="subj" value="Web Design"></dd>
<dd>Tech Support<input type="radio" name="subj" value="Tech Support"></dd>
<dd>Site Updates<input type="radio" name="subj" value="Site Updates"></dd>
<dd>All<input type="radio" name="subj" value="All"></dd>
</dl>
<input type="submit" value="View">
</form>
<?php }
if (isset($_POST['subj']))
{ $viewSub = $_POST['subj'];
if ($viewSub != "All")
{
$query = "SELECT * FROM `post` WHERE `$viewSub` = '{$row['subject']}'";
$result2 = mysql_query($query);
while($row2 = mysql_fetch_array($result2)){$posted = $row2[0]; }
}
else $posted = $row['post'];
}
//---------------------//
if (isset($viewSub))
{
if($username!=NULL){ ?><br><div align="left"><b><a href="addannouncement.php">Add An Announcement</a></b></div><br><? }?>
<table border="3">
<tr>
<?php if($username!=NULL){ ?><td align="center"><b>Options</b></td> <?php }?>
<td align="center"><b>Date</b></td>
<td align="center"><b>Anoucement</b></td>
<td align="center"><b>Posted By</b></td>
</tr>
<?php while($row=mysql_fetch_array($results))
{?>
<tr>
<?php if($username!=NULL){ ?><td><?php include('adminedit.php'); ?></td> <?php }?>
<td><?php echo date("d/m/y", $row{'date'}); ?></td>
<td valign="top"><?php echo $posted ?></td>
<td align="center" valign="middle"><?php echo $row{'username'}; ?></td>
</tr>
<?php
}
?>
</table>
<?php } ?>
<?php include('footer.php'); ?>