Home » Open Source » Programming Interfaces » Unloading from Oracle in PHP (windows7)
icon4.gif  Unloading from Oracle in PHP [message #661773] Fri, 31 March 2017 14:30 Go to next message
payrussia
Messages: 6
Registered: March 2017
Junior Member
Hello! Recently Orakl began to administer. My purpose: To create the website on which there will be customer information their gas stations of gasoline, each client will have the personal account.
Offer me convenient and simple option how to unload data from tables in HTML or PHP.
I want to study material, but in the Russian search engines of this material it is not enough, help to learn Orakl.
Re: Unloading from Oracle in PHP [message #661774 is a reply to message #661773] Fri, 31 March 2017 14:49 Go to previous messageGo to next message
Michel Cadot
Messages: 68624
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Here's a simple example of a PHP script to load the standard EMP table into your page:
<HTML>
<HEAD>
  <TITLE>EMP table</TITLE>
  <META NAME="Description" CONTENT="EMP table content.">
</HEAD>
<BODY BGCOLOR="#CCDDFF">
<?php
 if ($Con = oci_connect("$Account","$Password","$Base")) {
   $Query = "select empno, ename, job, mgr, hiredate, sal, comm, deptno from emp order by 1";
   print "</TABLE>\n";
   print "<TR>\n";
   print " <TD ALIGN=\"CENTER\"><FONT FACE=\"Arial\" SIZE=\"2\"><B>Empno</B></FONT></TD>\n";
   print " <TD ALIGN=\"CENTER\"><FONT FACE=\"Arial\" SIZE=\"2\"><B>Ename</B></FONT></TD>\n";
   print " <TD ALIGN=\"CENTER\"><FONT FACE=\"Arial\" SIZE=\"2\"><B>Job</B></FONT></TD>\n";
   print " <TD ALIGN=\"CENTER\"><FONT FACE=\"Arial\" SIZE=\"2\"><B>Mgr</B></FONT></TD>\n";
   print " <TD ALIGN=\"CENTER\"><FONT FACE=\"Arial\" SIZE=\"2\"><B>Hiredate</B></FONT></TD>\n";
   print " <TD ALIGN=\"CENTER\"><FONT FACE=\"Arial\" SIZE=\"2\"><B>Sal</B></FONT></TD>\n";
   print " <TD ALIGN=\"CENTER\"><FONT FACE=\"Arial\" SIZE=\"2\"><B>Comm</B></FONT></TD>\n";
   print " <TD ALIGN=\"CENTER\"><FONT FACE=\"Arial\" SIZE=\"2\"><B>Deptno</B></FONT></TD>\n";
   print "</TR>\n";
   $stmt = OCIParse($Con, $Query);
   $r = OCIExecute($stmt);
   while (OCIFetch($stmt)) {
     $empno    = OCIResult($stmt, 1);
     $ename    = OCIResult($stmt, 2);
     $job      = OCIResult($stmt, 3);
     $mgr      = OCIResult($stmt, 4);
     $hiredate = OCIResult($stmt, 5);
     $sal      = OCIResult($stmt, 6);
     $comm     = OCIResult($stmt, 7);
     $deptno   = OCIResult($stmt, 8);
     print "<TR>\n";
     print " <TD ALIGN=\"RIGHT\"><FONT FACE=\"Courier New\" SIZE=\"2\"> $empno </FONT></TD>\n";
     print " <TD ALIGN=\"LEFT\"><FONT FACE=\"Courier New\" SIZE=\"2\"> $ename </FONT></TD>\n";
     print " <TD ALIGN=\"LEFT\"><FONT FACE=\"Courier New\" SIZE=\"2\"> $job </FONT></TD>\n";
     print " <TD ALIGN=\"RIGHT\"><FONT FACE=\"Courier New\" SIZE=\"2\"> $mgr </FONT></TD>\n";
     print " <TD ALIGN=\"LEFT\"><FONT FACE=\"Courier New\" SIZE=\"2\"> $hiredate </FONT></TD>\n";
     print " <TD ALIGN=\"RIGHT\"><FONT FACE=\"Courier New\" SIZE=\"2\"> $sal </FONT></TD>\n";
     print " <TD ALIGN=\"RIGHT\"><FONT FACE=\"Courier New\" SIZE=\"2\"> $comm </FONT></TD>\n";
     print " <TD ALIGN=\"RIGHT\"><FONT FACE=\"Courier New\" SIZE=\"2\"> $deptno </FONT></TD>\n";
     print "</TR>\n";
   }
   print "</TABLE>\n";
 } else {
   $errmsg = oci_error();
   print 'Oracle connect error '. $errmsg['message'];
 }
?>
</BODY>
</HTML>
$Account, $Password and $Base are variables that are assumed to have been previously set (in another page).

Re: Unloading from Oracle in PHP [message #661775 is a reply to message #661774] Fri, 31 March 2017 15:07 Go to previous messageGo to next message
payrussia
Messages: 6
Registered: March 2017
Junior Member
MANY THANKS FRIEND, CAN YOU TELL ME LITERATURE ON THE LIST OF ALL COMMANDS FROM ORACLE TO PHP? I WILL TRY YOUR EXAMPLE TOMORROW. DEAR MODERATORS, DO NOT CLOSE THE TOPIC YET.

[Updated on: Fri, 31 March 2017 15:22]

Report message to a moderator

Re: Unloading from Oracle in PHP [message #661776 is a reply to message #661775] Sat, 01 April 2017 01:17 Go to previous messageGo to next message
Michel Cadot
Messages: 68624
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Oracle PHP Developer Center
Using PHP with Oracle Database 11g
The Underground PHP and Oracle Manual (free book to download from Oracle site).
OCI8 PHP manual (clear list but in French).

[We never close the topics, you can ever add something to it and it is appreciated.]

Re: Unloading from Oracle in PHP [message #661865 is a reply to message #661776] Tue, 04 April 2017 12:44 Go to previous messageGo to next message
payrussia
Messages: 6
Registered: March 2017
Junior Member
Good afternoon! At me it turned out to output data in the table. Now there was a question: There are numbers in a column 4,3,5. How to make that instead of figures words, заместо 4 = the house, 5 = the street and so on were substituted?
Re: Unloading from Oracle in PHP [message #661868 is a reply to message #661865] Tue, 04 April 2017 12:49 Go to previous messageGo to next message
Michel Cadot
Messages: 68624
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

I don't understand the question.
Post an example of the data you have:
desc <your table>
select <the relevant columns> from <your table> where rownum < 10;

Before, Please read How to use [code] tags and make your code easier to read.

Re: Unloading from Oracle in PHP [message #661870 is a reply to message #661868] Tue, 04 April 2017 22:38 Go to previous messageGo to next message
payrussia
Messages: 6
Registered: March 2017
Junior Member
No. It is necessary for me when data from оракл get in the table in the form of figures - were transferred to words. For example in the table there was figure 4 - and instead of her the word the house has been written.
Re: Unloading from Oracle in PHP [message #661871 is a reply to message #661870] Wed, 05 April 2017 00:38 Go to previous messageGo to next message
Michel Cadot
Messages: 68624
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

No about what?
You repeat and don't show, so I still don't understand.

Re: Unloading from Oracle in PHP [message #661876 is a reply to message #661871] Wed, 05 April 2017 01:10 Go to previous messageGo to next message
payrussia
Messages: 6
Registered: March 2017
Junior Member
it is necessary that in the oil column, instead of figures names were substituted. http:////s008.radikal.ru/i306/1704/f5/c269bd857b3a.jpg
Re: Unloading from Oracle in PHP [message #661877 is a reply to message #661876] Wed, 05 April 2017 01:10 Go to previous messageGo to next message
payrussia
Messages: 6
Registered: March 2017
Junior Member
understand?
Re: Unloading from Oracle in PHP [message #661878 is a reply to message #661877] Wed, 05 April 2017 01:17 Go to previous messageGo to next message
Michel Cadot
Messages: 68624
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

For me when oil is 2 the result should be Michel and when it is 3 it should be Cadot.

Re: Unloading from Oracle in PHP [message #661879 is a reply to message #661878] Wed, 05 April 2017 01:28 Go to previous messageGo to next message
Michel Cadot
Messages: 68624
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
With any SQL or PL/SQL question, please, Post a working Test case: create table (including all constraints) and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.
understand?

Re: Unloading from Oracle in PHP [message #661944 is a reply to message #661879] Thu, 06 April 2017 13:54 Go to previous message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
As far as I understand the problem, your current SELECT statement has to be modified in one of two ways. The first one is to hard-code those values using DECODE or CASE, such as
select 
  decode(oil, 2, 'AZS brook', 3, 'AZS willi') using_decode,
  case when oil = 2 then 'AZS brook'
       when oil = 3 then 'AZS willi'
  end using_case
...

Or, if "oil" description is (and yes, it probably should be) stored in another table, join these two tables, such as
select a.fio_client, a.city, b.oil_description
from current_table a, another_table b
where a.oil = b.oil
Previous Topic: 12c not connect with php see error Call to undefined function oci_connect()
Next Topic: Displaying Information based on entered value in PHP with Oracle Database 11g R2
Goto Forum:
  


Current Time: Thu Mar 28 09:33:04 CDT 2024