...

View Full Version : Viewing ALL threads.



NightFlyer
05-17-2008, 04:54 PM
Hey, I want it to view all threads from whatever the board ID is but it doesn't work.

viewthreads.php

<?php require_once("config.php");
$id = $_GET['id'];
$name = $_GET['name'];
$result = mysql_query("SELECT * FROM threads WHERE `id`='$id'") or die(mysql_error());

echo " <table border='1' 'width = 30%' > ";

// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<hr>";
echo $row['thread'] . '<a href="/forum/viewthread.php?id=' . $row['id'] . '">Go</a>';
echo "<hr>";
}
?>

addthread.php

<?php include("config.php");
$id =$_POST['id'];
$username = $_POST['username'];
$message =$_POST['message'];

mysql_query("INSERT INTO threads
(id,username,message) VALUES('$id','$username','$message' ) ")
or die(mysql_error()); ?>


new thread.php


<?php include("config.php");
$id = $_GET['id']; ?><table width="897" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="261" height="29" valign="top"><form name="form1" method="post" action="addthread.php">
<label>
<input type="text" name="name" id="message">
</label>
</form> </td>
<td width="636">&nbsp;</td>
</tr>
<tr>
<td height="185">&nbsp;</td>
<td>&nbsp;</td>
</tr>


</table>



I don't know what's wrong.

abduraooft
05-17-2008, 05:05 PM
mysql_query("INSERT INTO threads
(id,username,message) VALUES('$id','$username','$message' ) ")
The above query shows that your table threads has fields named id,username,message.

But here,
echo $row['thread'] . '<a href="/forum/viewthread.php?id=' . $row['id'] . '">Go</a>'; you are trying to print a value of field named thread

Hope this helps!

NightFlyer
05-17-2008, 05:22 PM
I don't really see what you mean.

abduraooft
05-17-2008, 05:24 PM
Try
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<hr>";
echo $row['message'] . '<a href="/forum/viewthread.php?id=' . $row['id'] . '">Go</a>';
echo "<hr>";
} instead.

NightFlyer
05-17-2008, 05:36 PM
Ok but now, I'ts not selecting boards now so that means it cannot get the board ID and every thread you make will be seperated. :(

And I'm not getting "message" I'm getting the thread titlte which would be "thread".

See what I'm trying to do is..

When you click a board it views all threads in that same category. WHat I have now is you have to type ?id=8 and it'll go to that thread, It will not put them in the board.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum