Solved

PHP: Count Rows in COM object array?

Posted on 2008-06-12
6
441 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
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…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

737 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