Link to home
Create AccountLog in
Avatar of SuprSpy79
SuprSpy79

asked on

PHP: Count Rows in COM object array?

I'm using php to work with a foxpro database.

using this select

$pricelist = "select * from PRODATA!ICITEM01 WHERE market1>0 ORDER BY itmdesc";

I need to count the number or rows (or better yet, actually see if it retrieved any data at all).
I know this can be done in my sql with mySQL_num_rows but working with com objects seems to be different so i dont think that would work.

Thansk in advance
ASKER CERTIFIED SOLUTION
Avatar of hernst42
hernst42
Flag of Germany image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of SuprSpy79
SuprSpy79

ASKER

so that will return a single number that i can print like echo $pricelist?
You can print it as you output the other things you read from the database.
how do i do  that?

normally i have to

$rs = $conn->Execute($pricelist);
$cntpatest = $rs->Fields("cntpa");
echo $cntpatest->value;

but this isnt returning any fields with values its returning a single number. Its returning as a vartiant so I cant  echo $rs
Should be printed with

$pricelist = "select count(*) as num from PRODATA!ICITEM01 WHERE market1>0 ORDER BY itmdesc";
$rs = $conn->Execute($pricelist);
$cntpatest = $rs->Fields("num");
echo $cntpatest->value;
great that worked, now i just need help with making my selects so i can compare the num of rows. here is the link

https://www.experts-exchange.com/questions/23479705/Need-Help-with-a-select.html