
June 9th, 2005
07:20 AM
Neversidian
Status: Offline!
count mysql rows
hi, im trying to count mysql rows, i know how to do this, but i want to count rows that are like, hmm how to say..
Well
i have a table like this:
threads
id - title - post - parent
and a row like this:
1 - hello - hi - 0
and
2 - hello2 - hi - 1
and i want to count the rows that have the parent part 1 and higher, i dont want rows that have the parent as 0, anyone know a way to do this?
___________________

Look at my super awsome pengy sig! | LiekOMG i found a super cool hosting site! click me to see - i rate it 10/10 pengys

June 9th, 2005
07:49 AM
Lost in Berkeley, CA
Status: Offline!
mmm i think this might work: thisnumber=mysql_query("select count(*) from `threads` where 'parent'=1"); someone correct me if i'm mistaken
___________________
There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.

June 9th, 2005
07:55 AM
I hate Customer Services!
Status: Offline!
In a similar kind of question I have a row called active in my tables, if I wanted to count all the rows that have 1 in that field how would I do?
___________________
PHP Freak Wannabe!

June 9th, 2005
08:38 AM
Neversidian
Status: Offline!
Originally posted by TheClincher:
mmm i think this might work: thisnumber=mysql_query("select count(*) from `threads` where 'parent'=1"); someone correct me if i'm mistaken
No that wont work for me
here is an example of a full table with rows:
table: threads
id - title - post - thread
rows:
1 - thread1 - testing - 0
2 - thread2 - testing - 0
3 - re: thread2 - test reply - 2
4 - re: thread1 - test reply - 1
now i want to count all rows that are greater then 0 if you know what i mean?
___________________

Look at my super awsome pengy sig! | LiekOMG i found a super cool hosting site! click me to see - i rate it 10/10 pengys

June 9th, 2005
08:42 AM
A webdesigner
Status: Offline!
$sql = "SELECT COUNT(*) FROM `threads` WHERE `parent` <> 0";
$result = mysql_query($sql);
I'l checkup when I get home.

June 9th, 2005
09:04 AM
Neversidian
Status: Offline!
Originally posted by Forge:
$sql = "SELECT COUNT(*) FROM `threads` WHERE `parent` <> 0";
$result = mysql_query($sql);
I'l checkup when I get home.
i use a class for my querys so yeah, but i got it working, i changed < > to > so its like
SELECT * FROM posts WHERE forum='$forumid' AND thread > 0
and it works fine, Thanks for the help 
___________________

Look at my super awsome pengy sig! | LiekOMG i found a super cool hosting site! click me to see - i rate it 10/10 pengys

June 9th, 2005
11:09 AM
A webdesigner
Status: Offline!
OK.
That's good to hear :-)