Count Query

Started on the old forum in December 2008 · view the original in the archive · old links redirect here

1 reply · 344 views · started 17 years ago · 1 min read

2 participants
Anshul Senior · 296 posts #1
TABLE `files` (
  `id` int(11) NOT NULL auto_increment,
  `infolder` text NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=5;

 TABLE `cats` (
  `id` int(10) NOT NULL auto_increment,
  `cat_sub` text NOT NULL,
  `cat_o` text NOT NULL,
  `type` tinyint(4) NOT NULL,
  PRIMARY KEY  (`cat_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=20;

I have these two database i wanna count the number of files from files database where infolder is cat_sub of the cats where type equal to 1 i am confuse in it lol if any can help then its high appreicated

I want to print them in loop like

$q_cats = @mysql_query("SELECT * FROM cats where type = '0' ORDER BY id ASC LIMIT $s,$l;");
while($cat = @mysql_fetch_array($q_cats))
 {
 echo"($subcat/$filescount)";
 }

subcat is category inside cats where cat_o is id the of category in which it is. and filescount is ..........

something else Fellow · 2,296 posts #2

what is $filescount? cos there is no indication to what that is. but you want it more like this:

 $q_cats = @mysql_query("SELECT * FROM cats where type = '0' ORDER BY id ASC LIMIT $s,$l;");
while($cat = @mysql_fetch_array($q_cats))
{
echo"($cat[1]/$cat[*?*])";
}

Change the ? to the apropriate item you are selecting 🙂

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