Solved

PHP: Count Rows in COM object array?

Posted on 2008-06-12
6
430 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

If I have to fix slow responding website my first thoughts are server side optimizations: the database may not be optimized or caching is not enabled, or things like that. We often overlook another major part of our web application: the client. We o…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

831 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