473,395 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

how do I print the result of a query to the screen.

36
I am trying to print the result of the query to the screen. For example Im looking to count the number of times REC appears in my db which is 3 times. So I could say select count(*).... which would output the number 3. When I put this into my code I only get 1. I get 1 no matter what happens. I looked up ociexecute and its 1 for success or 0 for fail. How would I accomplish this?Every example I see is too confusing.

Expand|Select|Wrap|Line Numbers
  1. //$db_conn = <the database connection info. >
  2. $query = "select count(*) from test_table";
  3. $parsed = ociparse($db_conn, $query);
  4. $succ = ociexecute($parsed);
  5.  
Jul 23 '07 #1
3 1376
code green
1,726 Expert 1GB
Don't despair. I can't see anything wrong with this so far.
You just haven't gone far enough.

The value returned by ociparse is a resource identifier.
ociexecute($parsed) executes the statement.
Note the resource identifier is passed in the function
Now you need to unravel the result.
You will need
Expand|Select|Wrap|Line Numbers
  1. oci_fetch_array ($parsed) 
  2. //or 
  3. oci_fetch_assoc ($parsed).
Your query will only return a count which should be the first array element
Expand|Select|Wrap|Line Numbers
  1. $query = "select count(*) from test_table";
So to see this figure use
[PHP]$result = oci_fetch_array($parsed);
$count = $result[0];
echo 'Count '.$count;[/PHP]I think this last bit is right. Apologies if not.
Jul 23 '07 #2
orfiyus
36
yo code green

Thanks alot man this helped me out alot. The only reason I needed to see the output on the screen was for debugging purposes. This really helped Ive been trying to get this output for at least 2 days. I have been looking all over google and I never found a clear answer. Anyway thanks for taking the time to look at this for me.

Peace
Jul 23 '07 #3
code green
1,726 Expert 1GB
No problem. I have never used the oci functions and I was curious to know whether they were similar to mysql,mssql and ODBC functions
Jul 27 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Ricki Susic | last post by:
Hi, Can anyone help me to get my query printed when I parse ID. Here is the code: FILE: udskriv.php <?php
4
by: Julie Siebel | last post by:
Apologies...I'm sure this has been asked before, but I can't seem to come up with the correct Google search terms. While my problem is with stylesheets, the errors are being caused by my...
48
by: David J Patrick | last post by:
I'm trying to rewrite the CSS used in http://s92415866.onlinehome.us/files/ScreenplayCSSv2.html. using the w3.org paged media standards as described at http://www.w3.org/TR/REC-CSS2/page.html ...
6
by: Nicolae Fieraru | last post by:
Hi All, I have a query, Select Count(BoolField) from tblMyTable, Where BoolField = true. If I run the query by itself, it returns the number of true records I want to use the result of that...
0
by: melanieab | last post by:
Hi, I have a tabpage with a print button. This button tries to do a print screen, and it works fine the first time, but if I try to press print again, I get error: An unhandled exception of type...
2
by: beary | last post by:
I have been stuck on a problem for 3 hours straight now. I am going crazy because this should be simple. (I am a relatively new mysql/php user, though) I have a mysql table with a field...
2
by: Ste | last post by:
Hi, I would like to print the current showing record from the Form screen but don't know where to start. Here are what I have: I can print any records from report built from query that has...
1
by: stcalixte | last post by:
First off, I really don't know much about Access, so please bear with me. Here's my problem. I have an Access file containing about 15 columns and 600 rows. Each cell in one of the columns...
12
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.