$newsid = $_GET['newsid'];
$query = "SELECT * FROM news JOIN members ON (news.newsAuthor=members.memberID) WHERE newsID='$newsid'";
$query2 = "SELECT * FROM comments JOIN members ON (comments.commentAuthor=members.memberID) WHERE newsID='$newsid'";
$result = mysql_query($query);
$result2 = mysql_query($query2);
while ($list = mysql_fetch_array($result)) {
echo "<table width=\"500\">";
echo "<tr>";
echo "<th>DateTime</th>";
echo "<th>Author</th>";
echo "<th>Title</th>";
echo "</tr>";
echo "<tr>";
echo "<td>{$list['newsDateTime']}</td>";
echo "<td class=\"tdwidth\"><a href=\"..\memberpages\viewmember.php?memberID=$list[memberID]\">{$list['name']}</a></td>";
echo "<td>{$list['newsTitle']}</td>";
echo "</tr>";
echo "<tr>";
echo "<th colspan=\"3\">News Item</th>";
echo "</tr>";
echo "<tr>";
echo "<td colspan=\"3\">{$list['newsItem']}</td>";
echo "</tr>";
echo "<tr>";
echo "<td colspan=\"3\"><a href=\"viewcomments.php?newsid=$list[newsID]\">View Comments</a></td>";
echo "</tr>";
echo "</table>";
echo "<br/>";
}
while ($list2 = mysql_Fetch_array($result2)) {
echo "<table width=\"500\">";
echo "<tr>";
echo "<th>Comment From</th>";
echo "<th>Date/Time</th>";
echo "</tr>";
echo "<tr>";
echo "<td><a href=\"..\memberpages\viewmember.php?memberID=$list2[memberID]\">{$list2['name']}</a></td>";
echo "<td>{$list2['commentDateTime']}</td>";
echo "</tr>";
echo "<tr>";
echo "<th colspan=\"2\">Comment</th>";
echo "</tr>";
echo "<tr>";
echo "<td colspan=\"2\">{$list2['comment']}</td>";
echo "</tr>";
echo "</table>";
echo "<br/>";
}
include 'addnewscomment-form.php';
?>
Above GETS the memberID from a previous page fine.
-----------------------
addnewscomment-form.php
<?php session_start();?>
<form action="addnewscomment-process.php" method="post">
<p>
<label for="newscomment">Comment On This News Item:</label><br/><br/>
<textarea rows="5" cols="30" name="newscomment" id="newscomment"></textarea>
</p>
<p>
<input type="submit" value="submit" name="submit"/>
</p>
</form>
the process form - adds stuff to the db
<?php
mysql_connect('socweb1.napier.ac.uk', 'a5013885', '3ball');
$db_selected = mysql_select_db('a5013885');
if (!$db_selected) {
die('Can\'t use a5013885 : ' . mysql_error());
}
if (!empty($_POST['newscomment'])){
$newscomment = $_POST['newscomment'];
}
echo $newscomment;
mysql_query($query) or die('Insert Failed - Probably dodgy coding at the mo.');
echo "<p>News comment added!</p><br/>";
echo "<p>Click <a href=\"index.php\">Here</a> to return to the main page</p>";
?>
I'm echoing $newscomment to make sure it goes across (it does).
I want to chuck the $memberID through too so I can add it to the database table comments under a field called commentAuthor.
Any help would be appreciated as this problem is throwing me out a few times in similar situations. Then thats me finished apart from one other problem.
A session problem but i'm gonna go ask Andrew Cumming in the morning (work doesn't have to be in till 3 pm) about that.
Thank youuuuuu xx