help in select count comment

Started on the old forum in May 2009 · view the original in the archive · old links redirect here

3 replies · 446 views · started 17 years ago · 1 min read

2 participants
wapmetal Lead · 609 posts #1

$nopl = "SELECT id, title, itemurl, uid, pudt, descarcat, descriere ,des ,comment, fileid FROM come4me_wapchat_categorii_download WHERE cid='".$cid."';

this is in comment

else if ($action=="comments"){

    $fileid = $_GET["fileid"];
    $uid = getuid_sid($sid);
    if($page=="" || $page<=0)$page=1;
    $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM iw_comup WHERE fileid='".$fileid."'"));
    $num_items = $noi[0]; //changable
    $items_per_page= 5;
    $num_pages = ceil($num_items/$items_per_page);
    if(($page>$num_pages)&&$page!=1)$page= $num_pages;
    $limit_start = ($page-1)*$items_per_page;

    
        $sql = "SELECT fileid, commenter, comment, time, id FROM iw_comup WHERE fileid='".$fileid."' ORDER BY time DESC LIMIT $limit_start, $items_per_page";

////boxstart("File Comments");
    
    $items = mysql_query($sql);
    echo mysql_error();
    if(mysql_num_rows($items)>0)
    {
    while ($item = mysql_fetch_array($items))
    {
        
          if(isonline($item[1]))
  {
    $iml = "<img src=\"http://coding-talk.com/images/onl.gif\" alt=\"+\"/>";
    
  }else{
    $iml = "<img src=\"http://coding-talk.com/images/ofl.gif\" alt=\"-\"/>";
  }
    $snick = getnick_uid($item[1]);
      $lnk = "<a href=\"index.php?action=viewuser&who=$item[1]&sid=$sid\">$snick</a>";
      $bs = date("d/m/y h:i:s A",$item[3] + addhours());
      echo "$lnk<br/>";
      if(ismod($uid))
      {
        $delnk = "<a href=\"share.php?action=delcmnt&sid=$sid&fileid=$item[4]\">[x]</a>";
      }else{
        $delnk = "";
      }
      $text = parsepm($item[2]);
      echo "$text<br/>$bs $delnk<br/>";
    }
    }
    echo "<p align=\"center\">";
    if($page>1)
    {
      $ppage = $page-1;
      echo "<a href=\"share.php?action=$action&page=$ppage&sid=$sid&fileid=$fileid\">«PREV</a> ";
    }
    if($page<$num_pages)
    {
      $npage = $page+1;
      echo "<a href=\"share.php?action=$action&page=$npage&sid=$sid&fileid=$fileid\">Next»</a>";
    }
    echo "<br/>Page $page of $num_pages<br/>";
    if($num_pages>2){
        $rets = "<form action=\"share.php\" method=\"get\">Jump to page<input name=\"pg\" format=\"*N\" size=\"3\"/>";
        $rets .= "<input type=\"hidden\" name=\"action\" value=\"$action\"/>";
        $rets .= "<input type=\"hidden\" name=\"fileid\" value=\"$fileid\"/>";
        $rets .= "<input type=\"hidden\" name=\"sid\" value=\"$sid\"/>";
	$rets .= "<input id=\"inputButton\" type=\"submit\" value=\"Go\"/>";
        $rets .= "</form>";	    
    }
         echo $rets;
     echo "</p>";
  ////// UNTILL HERE >>
    echo "<p align=\"center\">";
   echo "<a href=\"share.php?action=addcmnt&sid=$sid&fileid=$fileid\">";
echo "Add your comment</a></p>";
}
////////////////////////////////////Post a comment(downloaders)////////////////////

$nopl = "SELECT id, title, itemurl, uid, pudt, descarcat, descriere ,des ,comment, fileid FROM come4me_wapchat_categorii_download WHERE cid='".$cid."';

echo "comments nopl[0]";

it is not working... wrong, showing comment counts ...pls...help

CreativityKills Lead · 833 posts #2

wapmetal wrote: $nopl = "SELECT id, title, itemurl, uid, pudt, descarcat, descriere ,des ,comment, fileid FROM come4me_wapchat_categorii_download WHERE cid='".$cid."';

this is in comment

else if ($action=="comments"){

$fileid = $_GET["fileid"];
$uid = getuid_sid($sid);
if($page=="" || $page<=0)$page=1;
$noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM iw_comup WHERE fileid='".$fileid."'"));
$num_items = $noi[0]; //changable
$items_per_page= 5;
$num_pages = ceil($num_items/$items_per_page);
if(($page>$num_pages)&&$page!=1)$page= $num_pages;
$limit_start = ($page-1)*$items_per_page;


    $sql = "SELECT fileid, commenter, comment, time, id FROM iw_comup WHERE fileid='".$fileid."' ORDER BY time DESC LIMIT $limit_start, $items_per_page";

////boxstart("File Comments");

$items = mysql_query($sql);
echo mysql_error();
if(mysql_num_rows($items)>0)
{
while ($item = mysql_fetch_array($items))
{
    
      if(isonline($item[1]))

{ $iml = "<img src="images/onl.gif" alt="+"/>";

}else{ $iml = "<img src="images/ofl.gif" alt="-"/>"; } $snick = getnick_uid($item[1]); $lnk = "<a href="index.php?action=viewuser&who=$item[1]&sid=$sid">$snick</a>"; $bs = date("d/m/y h:i:s A",$item[3] + addhours()); echo "$lnk "; if(ismod($uid)) { $delnk = "<a href="share.php?action=delcmnt&sid=$sid&fileid=$item[4]">[x]</a>"; }else{ $delnk = ""; } $text = parsepm($item[2]); echo "$text $bs $delnk "; } } echo " "; if($page>1) { $ppage = $page-1; echo "<a href="share.php?action=$action&page=$ppage&sid=$sid&fileid=$fileid">«PREV</a> "; } if($page<$num_pages) { $npage = $page+1; echo "<a href="share.php?action=$action&page=$npage&sid=$sid&fileid=$fileid">Next»</a>"; } echo " Page $page of $num_pages "; if($num_pages>2){ $rets = "<form action="share.php" method="get">Jump to page<input name="pg" format="*N" size="3"/>"; $rets .= "<input type="hidden" name="action" value="$action"/>"; $rets .= "<input type="hidden" name="fileid" value="$fileid"/>"; $rets .= "<input type="hidden" name="sid" value="$sid"/>"; $rets .= "<input id="inputButton" type="submit" value="Go"/>"; $rets .= "</form>";
} echo $rets; echo " "; ////// UNTILL HERE >> echo " "; echo "<a href="share.php?action=addcmnt&sid=$sid&fileid=$fileid">"; echo "Add your comment</a> "; } ////////////////////////////////////Post a comment(downloaders)////////////////////

$nopl = "SELECT id, title, itemurl, uid, pudt, descarcat, descriere ,des ,comment, fileid FROM come4me_wapchat_categorii_download WHERE cid='".$cid."';

echo "comments nopl[0]";

it is not working... wrong, showing comment counts ...pls...help

i dont really understand your question but if you want to know how many comments that particular category has? or the particular file?

Anyways it should be sumthing like this if thats what you want:

$numcom = mysql_fetch_array(mysql_query("SELECT COUNT(*) WHERE cid='".$cid."'"));

echo "Comments: ".$numcom[0];

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close