Thread: duplicate columns


Permlink Replies: 4 - Pages: 1 - Last Post: Jan 4, 2007 11:26 AM Last Post By: cj2
sadora

Posts: 3
Registered: 06/11/99
duplicate columns
Posted: Sep 7, 2006 4:25 AM
Click to report abuse...   Click to reply to this thread Reply
Can you tell me why I got duplicate columns when I try to run example from 2 Day Plus PHP Developer Guide - B25317-01

===================================================
<?php
require('anyco_ui.inc');

// Create a database connection
$conn = oci_connect('hr','hr','mytcp');
ui_print_header('== Departments ==');
do_query($conn,'SELECT * FROM DEPARTMENTS');
ui_print_footer(date('Y-m-d H:i:s'));

// Execute query and display results
function do_query($conn,$query)
{
$stid = oci_parse($conn,$query);
$r = oci_execute($stid, OCI_DEFAULT);

print '<table border="1">';
while($row = oci_fetch_array($stid, OCI_RETURN_NULLS)){
print '<tr>';
foreach ($row as $item) {
print '<td>'
.($item ? htmlentities($item): ' ').'</td>';
}
print '</tr>';
}
print '</table>';
}

?>
=========================================

Everything looks fine but in response I got HTML table with duplicated columns.
IngramIFP

Posts: 75
Registered: 05/24/06
Re: duplicate columns
Posted: Sep 7, 2006 4:49 AM   in response to: sadora in response to: sadora
Click to report abuse...   Click to reply to this thread Reply
Can you provide a sample of the output with duplicate columns please.

TY
sadora

Posts: 3
Registered: 06/11/99
Re: duplicate columns
Posted: Sep 7, 2006 4:04 PM   in response to: IngramIFP in response to: IngramIFP
Click to report abuse...   Click to reply to this thread Reply
Yes, i try to show what it looks like.
In HTML it looks like that
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equive="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Any Co.: == Departments ==</title>
</head>
<body>

== Departments ==

<table border="1">
<tr>
<td>10</td>
<td>10</td>
<td>Administration</td>
<td>Administration</td>
<td>200</td>
<td>200</td>
<td>1700</td>
<td>1700</td>
</tr>
<tr>
<td>20</td>
<td>20</td>
<td>Marketing</td>
<td>Marketing</td>
<td>201</td>
<td>201</td>
<td>1800
</td>
<td>1800</td>
</tr>
<tr>
<td>30</td>
<td>30</td>
<td>Purchasing</td>
<td>Purchasing</td>
<td>114</td>
<td>114</td>
<td>1700</td>
<td>1700</td>
</tr>
<tr><
td>40</td>
<td>40</td>
<td>Human Resources</td>
<td>Human Resources</td>
<td>203</td>
<td>203</td>
<td>2400</td>
<td>2400</td>
</tr>
<tr>
<td>50</td>
<td>50</td>
<td>Shipping</td>
<td>Shipping</td>
<td>121</td><td>121</td><td>1500</td><td>1500</td></tr><tr><td>60</td><td>60</td><td>IT</td><td>IT</td><td>103</td><td>103</td><td>1400</td><td>1400</td></tr><tr><td>70</td><td>70</td><td>Public Relations</td><td>Public Relations</td><td>204</td><td>204</td><td>2700</td><td>2700</td></tr><tr><td>80</td><td>80</td><td>Sales</td><td>Sales</td><td>145</td><td>145</td><td>2500</td><td>2500</td></tr><tr><td>90</td><td>90</td><td>Executive</td><td>Executive</td><td>100</td><td>100</td><td>1700</td><td>1700</td></tr><tr><td>100</td><td>100</td><td>Finance</td><td>Finance</td><td>108</td><td>108</td><td>1700</td><td>1700</td></tr><tr><td>110</td><td>110</td><td>Accounting</td><td>Accounting</td><td>205</td><td>205</td><td>1700</td><td>1700</td></tr><tr><td>120</td><td>120</td><td>Treasury</td><td>Treasury</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>130</td><td>130</td><td>Corporate Tax</td><td>Corporate Tax</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>140</td><td>140</td><td>Control And Credit</td><td>Control And Credit</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>150</td><td>150</td><td>Shareholder Services</td><td>Shareholder Services</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>160</td><td>160</td><td>Benefits</td><td>Benefits</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>170</td><td>170</td><td>Manufacturing</td><td>Manufacturing</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>180</td><td>180</td><td>Construction</td><td>Construction</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>190</td><td>190</td><td>Contracting</td><td>Contracting</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>200</td><td>200</td><td>Operations</td><td>Operations</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>210</td><td>210</td><td>IT Support</td><td>IT Support</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>220</td><td>220</td><td>NOC</td><td>NOC</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>230</td><td>230</td><td>IT Helpdesk</td><td>IT Helpdesk</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>240</td><td>240</td><td>Government Sales</td><td>Government Sales</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>250</td><td>250</td><td>Retail Sales</td><td>Retail Sales</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>260</td><td>260</td><td>Recruiting</td><td>Recruiting</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>270</td><td>270</td><td>Payroll</td><td>Payroll</td><td></td><td></td><td>1700</td><td>1700</td></tr></table>
user551542

Posts: 1
Registered: 01/04/07
Re: duplicate columns
Posted: Jan 4, 2007 10:01 AM   in response to: sadora in response to: sadora
Click to report abuse...   Click to reply to this thread Reply
did you ever get an answer to this? I can't figure it out either.
cj2

Posts: 759
Registered: 01/10/01
Re: duplicate columns
Posted: Jan 4, 2007 11:26 AM   in response to: user551542 in response to: user551542
Click to report abuse...   Click to reply to this thread Reply
The oci_fetch_array() call now returns the data indexed both
numerically and associatively. The Oracle guide was written prior to
this change in PHP. The doc writer has been informed of the
correction:

Change code line, adding "OCI_ASSOC+", to read:
       while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {

This is due to PHP's fix for http://bugs.php.net/bug.php?id=37487

-- cj

Legend
Guru Guru : 2500 - 1000000 pts
Expert Expert : 1000 - 2499 pts
Pro Pro : 500 - 999 pts
Journeyman Journeyman : 200 - 499 pts
Newbie Newbie : 0 - 199 pts
Oracle ACE Director
Oracle ACE Member
Oracle Employee ACE
Helpful Answer (5 pts)
Correct Answer (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums