Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    May 2008
    Posts
    94
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Adding Thread help (Forum)

    I'm making a forum from scratch.

    I have made the boards which is also the category and if the board ID is 7 it will go to the thread that is ID 7 but I don't want that. I want it where when you click a board it goes and views the threads.

    Viewthread.php
    PHP Code:
    <?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 
    "<b>Username:</b> "; echo ''.$row['name'];
        echo 
    "<hr>"
        }
        
    ?>
    Addthread.php
    PHP Code:
    <?php include("config.php");
    $name $_POST['name'];

    mysql_query("INSERT INTO threads 
    (name) VALUES('$name' ) "

    or die(
    mysql_error());  ?>
    Please help thanks
    Last edited by NightFlyer; 05-16-2008 at 11:17 PM.

  • #2
    New Coder
    Join Date
    May 2008
    Posts
    94
    Thanks
    11
    Thanked 0 Times in 0 Posts
    Anyone?

  • #3
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Your question is confusing. You need to abstract it more.

  • #4
    New Coder
    Join Date
    May 2008
    Posts
    94
    Thanks
    11
    Thanked 0 Times in 0 Posts
    READ IT aGaIn i eDiTEd iT.>.>.>

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    No need to shout mate.
    Well, I'm with aedrin on this one for sure. The code you have posted is to display a specific thread and how to add a new thread. I don't see anything that refers to the actual board itself. So I'm not sure what you are looking for either. Fetching all the threads info isn't a good idea if you want to display it on a 'board' type listing, like we have here, so you would select say the thread title, maybe the thread author and dates, and of course the thread id. Do this all on a where clause for the board you are looking for, and you should get a list of all the threads associated with that category and you can loop through them. This of course assumes that you are referring to a specific board/category within each of your threads - otherwise you need to specify your database schema so we can see if there is away around it.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #6
    New Coder
    Join Date
    May 2008
    Posts
    94
    Thanks
    11
    Thanked 0 Times in 0 Posts
    Oh I see. Thanks
    PS. I was axednetly on caps lock :/

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Thats ok mate, no worries.
    Is this what you are looking to do though, does it answer what you are looking for?
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #8
    New Coder
    Join Date
    May 2008
    Posts
    94
    Thanks
    11
    Thanked 0 Times in 0 Posts
    Kinda. Now all I need is help with replying to a thread. Here is what I have.

    addreply.php
    PHP Code:
    <?php require_once("config.php"); 
    $id =$_POST['id'];

    $username=$_POST['username'];
    $message=$_POST['message'];

    mysql_query("INSERT INTO boards(rusername,rmessage)Values('$rusername','$rmessage')") or die(mysql_error());
    ?>
    viewthread.php
    PHP Code:
    <?php require_once("config.php"); 
    $id $_GET['id'];
    $name $_GET['name'];
    $rusername =$_GET['rusername'];
    $rmessage=$_GET['rmessage']; 
    $result mysql_query("SELECT * FROM boards 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 
    "<b>Username:</b> "; echo ''.$row['message'];
        echo 
    "<hr>"
        echo 
    '<a href="/forum/replybox.php?id=' $row['id'] . '">Go view replies</a>';
        }
        
    ?>
    See my problem is, There is no select from threads and I cannot have two querys in there on the same page.

    So I don't know what to do

  • #9
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Without your database schema I cannot really help you all that much.
    But, I can tell you you can have as many queries as you want on a page (limited by the memory of course, but that will take awhile ), and don't forget you can join your SQL queryies if you need to.
    For example, using a join (not sure if it relates to your tables or not, but its just an example):
    Code:
    SELECT t.*, c.categoryName FROM `thread` t INNER JOIN `category` c ON (t.catID = c.catID) WHERE t.tID = 5
    That would get all the information about thread with the ID of 5, and the category name associated with that threads category ID.

    Search the net for 'SQL Join', if you need more examples, there are many different joins available, and they are extremely helpful
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #10
    New Coder
    Join Date
    May 2008
    Posts
    94
    Thanks
    11
    Thanked 0 Times in 0 Posts
    Thanks but I don't think I need that.

    When you click a board in here it'll show threads from the board. In my case it will only show one thread. It keeps making IDs of threads and not putting the ids in the id of the board so it's all spreded out.

    In that case it has something to do with:

    addtopic.php

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

    mysql_query("INSERT INTO threads 
    (username,message) VALUES('$username','$message' ) "

    or die(
    mysql_error());  ?>
    Or/And

    createtopic.php

    PHP Code:
    <?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>
    Last edited by NightFlyer; 05-17-2008 at 06:26 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •