Solved

PHP: Count Rows in COM object array?

Posted on 2008-06-12
6
419 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.

910 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

22 Experts available now in Live!

Get 1:1 Help Now