?
Solved

PHP: Count Rows in COM object array?

Posted on 2008-06-12
6
Medium Priority
?
475 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 2000 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses
Course of the Month17 days, 10 hours left to enroll

830 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