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]
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.