i've been working on my blog/thoughtrepository or awhile now, and i only have 1 more bug. I'm trying to get the "view.gif" to show up only when that $postid is found in the database. My problem is that its showing the view.gif EVERYTIME its found in the database. I've tried all different things....The part i'm having problems with is the nested while statement (the one with $row99) I want it to search the database for the current $postid, and if it finds it, print the picture, and then stop that nested while statement so the parent while statement and continue. Any ideas how i'd go about doing this?

$query = "SELECT today, entry, id FROM thought_posts order by id desc LIMIT 0,5";
   $result = mysql_query($query) or die("Query failed : " . mysql_error());

   /* Printing results in HTML */
  while($row=mysql_fetch_row($result))
   {
$postid=$row[2];
print "<table border='1' cellpadding='6' cellspacing='5' style='border-collapse: collapse' bordercolor='#D4D4D4' width='565' id='AutoNumber1' bgcolor=#FFFFFF>";
    print "<tr>";
       print "<td bordercolorlight='#FFFFFF' bordercolordark='#FFFFFF'><p><b>$row[0]</b></td>";
      print "<td bordercolorlight=#FFFFFF bordercolordark=#FFFFFF><p align='right'>";
$match=false;
mysql_select_db('xxx');
$query99 = 'SELECT postid FROM thought_reply';
$result99 = mysql_query($query99) or die('Query failed : ' . mysql_error());

  while($row99=mysql_fetch_row($result99))
   {
  if($postid==$row99[0])
   {
    $match=true;
   }
if($match)
{
print "<a href=\"javascript:openWindow('notes.php?postid=$postid','notes','370','300','1','1')\" style=\"text-decoration: none\"'><img src='img/view.gif' border='0'></a>";
$match=false;
}
else
{
} 
}
print "<a href=\"javascript:openWindow('write.php?postid=$postid','notes','370','300','1','1')\" style=\"text-decoration: none\"'><img src='img/write.gif' border='0'></a><a href='#top'><img border='0' src='img/up.gif'></a></p></td>";
    print "</tr>";
    print "<tr>";
      print "<td colspan=2 bordercolorlight=#FFFFFF bordercolordark=#FFFFFF><p>$row[1]</td>";
    print "</tr>";
  print "</table>";
print "<br>";
   }

    why does it keep saying redface.gif? thats not what i posted, but nonetheless, forget that, vbulletin must be inserting that in?

      You can use "break" to end a while loop. See
      http://www.php.net/break

      In your case though, I would suggest that instead
      of doing a SQL select to suck down a whole table
      and then count the matching lines, instead use
      SQL to count the occurances. So instead of this:

      SELECT postid FROM thought_reply

      use this:

      select count(*) from thought_reply where postid = $postid

      When you go mysql_fetch_row you will get a
      single row with a single value representing the
      count. If it's non-zero then there is a post with
      $postid in the DB.

      This is better because you can create an index on
      the postid column in the database, and mysql can
      perform the query without actually looking at the
      entire table.

        Originally posted by jdnet
        why does it keep saying redface.gif? thats not what i posted, but nonetheless, forget that, vbulletin must be inserting that in?

        Disable smilies when you post.

          Write a Reply...