Jump to content

Showing Information From Certain Table Row


Unholy Prayer

Recommended Posts

Ok, so far so good... not getting any error messages when I click on the link to the forum from the index, but there aren't any threads in it yet.  How do I display a message saying that there aren't any?  Here is my code:
[code]<?php
include('styles/default/page_header.tpl');

require_once('config.php');

$fid = $_GET['id'];

echo "<table align='center' width='95%' cellspacing='1' cellpadding='1' border='0' class='table'>
        <tr>
          <td colspan='4' class='bgcat>Viewing Threads in: $forumname</td>
        </tr><tr>
          <td align='left' width='50%' class='cellnames'>Thread Subject</td>
          <td align='left' width='20%' class='cellnames'>Thread Starter</td>
          <td align='left' width='10%' class='cellnames'>Replies</td>
          <td align='left' width='20%' class='cellnames'>Last Updated</td>
        </tr><tr>";

$threads = mysql_query("select * from threads where fid = $fid order by id");

while($t=mysql_fetch_array($threads))

  {
      $id=$t["id"];
      $author=$t["author"];
      $subject=$t["subject"];
      $message=$t["message"];
      $date=$t["date"];
      $time=$t["time"];
  echo "<td align='left' width='50%' class='forumrow'><a href='viewthread.php?id=$id'>$subject</a></td>
        <td align='left' width='20%' class='forumrow'>$author</td>
        <td align='left' width='10%' class='forumrow'>0</td>
        <td align='left' width='20%' class='forumrow'>On $date at $time</td>
      </tr><tr>";
  }
?>[/code]
Link to comment
Share on other sites

not sure if this is the best way but you could do this

[quote]<?php
include('styles/default/page_header.tpl');

require_once('config.php');

$fid = $_GET['id'];

echo "<table align='center' width='95%' cellspacing='1' cellpadding='1' border='0' class='table'>
        <tr>
          <td colspan='4' class='bgcat>Viewing Threads in: $forumname</td>
        </tr><tr>
           <td align='left' width='50%' class='cellnames'>Thread Subject</td>
           <td align='left' width='20%' class='cellnames'>Thread Starter</td>
           <td align='left' width='10%' class='cellnames'>Replies</td>
           <td align='left' width='20%' class='cellnames'>Last Updated</td>
        </tr><tr>";

$threads = mysql_query("select * from threads where fid = $fid order by id");

if($threads == " "){
echo "No threads to display";
}
while($t=mysql_fetch_array($threads))

  {
      $id=$t["id"];
      $author=$t["author"];
      $subject=$t["subject"];
      $message=$t["message"];
      $date=$t["date"];
      $time=$t["time"];
  echo "<td align='left' width='50%' class='forumrow'><a href='viewthread.php?id=$id'>$subject</a></td>
        <td align='left' width='20%' class='forumrow'>$author</td>
        <td align='left' width='10%' class='forumrow'>0</td>
        <td align='left' width='20%' class='forumrow'>On $date at $time</td>
       </tr><tr>";
   }
?>[/quote]

Like I said there is probably a better way,.. but that should work
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.