Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

94 users online



count mysql rows

count mysql rows

Currently viewing this thread: 1 (0 members and 1 guests)


Pengy

Pengy

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?

___________________

http://pengy.cjb.net/sig.php
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

TheClincher

TheClincher

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.

tcbil

tcbil

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!

Pengy

Pengy

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?

___________________

http://pengy.cjb.net/sig.php
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

Forge

Forge

A webdesigner
Status: Offline!

$sql = "SELECT COUNT(*) FROM `threads` WHERE `parent` <> 0";
$result = mysql_query($sql);

I'l checkup when I get home.

Pengy

Pengy

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 Smile

___________________

http://pengy.cjb.net/sig.php
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

Forge

Forge

A webdesigner
Status: Offline!

OK.
That's good to hear :-)

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0078 seconds.