Solved

PHP: Count Rows in COM object array?

Posted on 2008-06-12
6
415 Views
Last Modified: 2008-06-12
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
0
Comment
Question by:SuprSpy79
  • 3
  • 3
6 Comments
 
LVL 48

Accepted Solution

by:
hernst42 earned 500 total points
ID: 21769634
run
$pricelist = "select count(*) as num from PRODATA!ICITEM01 WHERE market1>0 ORDER BY itmdesc";
and read that result and it will tell you the number of rows.
0
 
LVL 5

Author Comment

by:SuprSpy79
ID: 21769757
so that will return a single number that i can print like echo $pricelist?
0
 
LVL 48

Expert Comment

by:hernst42
ID: 21769786
You can print it as you output the other things you read from the database.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 5

Author Comment

by:SuprSpy79
ID: 21769856
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
0
 
LVL 48

Expert Comment

by:hernst42
ID: 21770000
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;
0
 
LVL 5

Author Comment

by:SuprSpy79
ID: 21770093
great that worked, now i just need help with making my selects so i can compare the num of rows. here is the link

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_23479705.html
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses four methods for overlaying images in a container on a web page
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now