corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Geek Day » SQL - Oracle - PHP


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author SQL - Oracle - PHP
Dan Lewis
Member

Registered: 31st Jan 05
Location: Leicestershire
User status: Offline
29th Jan 09 at 09:47   View User's Profile U2U Member Reply With Quote

I'm looking for information on how to go about exporting data.

This connects to the oracle database and pulls the user names.

code:
<!-- start content -->
<div id=content>
<div class=post>
<h1 class=title><a href=#>SoD Analyzer</a></h1>
<div class=entry>

<form name=resp_gen method=post action=User_Resp_Creation_process.php>
<table>
<tr>
<td>Username to be Checked(*):</td>
<td>
<select name=username_to_be_checked>

<?
$ORACLE_CONNECT = OCILogon($ORACLE_USERNAME, $ORACLE_PASSWORD, $ORACLE_SID);

$query_username_to_be_checked = "
SELECT DISTINCT USER_NAME
FROM FND_USER
WHERE (END_DATE IS NULL
OR END_DATE > SYSDATE)
ORDER BY USER_NAME
";

$ORACLE_STATIC = OCIParse($ORACLE_CONNECT, $query_username_to_be_checked);
OCIExecute($ORACLE_STATIC, OCI_DEFAULT);

while ($PRINT_RECORD = oci_fetch_array ($ORACLE_STATIC, OCI_BOTH))
{
echo "<option value=" . $PRINT_RECORD[0] . ">" . $PRINT_RECORD[0] . "</option>";
}

?>
</select>
</tr>

<tr>
<td colspan=2 align=center><input type=submit name=submit value=Generate List></td>
</tr>

</table>
</form>

</div>
</div>
</div>
<!-- end content -->


I then have another part that connects to our sql data base and pulls out some data.

So it goes,

Oracle- Username
SQL- Data

How would i get the two to combine and export as a csv file.
Sam
Moderator
Premium Member


Registered: 24th Dec 99
Location: West Midlands
User status: Offline
29th Jan 09 at 10:18   View User's Profile U2U Member Reply With Quote

Temporarily store the data in an XML file or an array, then format those values using PHP's CSV functions, then write to a file

http://uk3.php.net/manual/en/function.fputcsv.php


[Edited on 29-01-2009 by Sam]
Dan Lewis
Member

Registered: 31st Jan 05
Location: Leicestershire
User status: Offline
29th Jan 09 at 10:19   View User's Profile U2U Member Reply With Quote

im new to all this, just created that to connect and view the names doing the sql part now.
Sam
Moderator
Premium Member


Registered: 24th Dec 99
Location: West Midlands
User status: Offline
29th Jan 09 at 10:21   View User's Profile U2U Member Reply With Quote

Try this Dan:

http://www.ineedtutorials.com/articles/export-mysql-data-to-csv-php-tutorial
Dan Lewis
Member

Registered: 31st Jan 05
Location: Leicestershire
User status: Offline
29th Jan 09 at 11:06   View User's Profile U2U Member Reply With Quote

Ive got the arrays sorted now thanks sam
Sam
Moderator
Premium Member


Registered: 24th Dec 99
Location: West Midlands
User status: Offline
29th Jan 09 at 11:58   View User's Profile U2U Member Reply With Quote

Dan Lewis
Member

Registered: 31st Jan 05
Location: Leicestershire
User status: Offline
30th Jan 09 at 13:40   View User's Profile U2U Member Reply With Quote

Have another thing now...


code:
<? include("header.inc.php"); ?>

<!-- start content -->
<div id=content>
<div class=post>
<h1 class=title><a href=#>SoD Analyzer</a></h1>
<div class=entry>
<form name=resp_gen method=post action=User_Resp_Creation_process.php>
<table>
<tr>
<td>Username to be Checked(*):</td>
<td>
<select name=username_to_be_checked>
<?
$ORACLE_CONNECT = OCILogon($ORACLE_USERNAME, $ORACLE_PASSWORD, $ORACLE_SID);
$query_username_to_be_checked = "
SELECT DISTINCT USER_NAME
FROM FND_USER
WHERE (END_DATE IS NULL
OR END_DATE > SYSDATE)
ORDER BY USER_NAME
";
$ORACLE_STATIC = OCIParse($ORACLE_CONNECT, $query_username_to_be_checked);
OCIExecute($ORACLE_STATIC, OCI_DEFAULT);

while ($PRINT_RECORD = oci_fetch_array ($ORACLE_STATIC, OCI_BOTH))
{
echo "<option value=" . $PRINT_RECORD[0] . ">" . $PRINT_RECORD[0] . "</option>";
}
?>

<select name=Respon>
<?
$list=mysql_query("SELECT RESP_GROUP, RESPONSIBILITY FROM FOX_MASTER_ACCESS_GROUPS");

while($row_list=mysql_fetch_assoc($list)){
?>
<option value="<? echo $row_list['RESPONSIBILITY']; ?>" <? if($row_list['RESPONSIBILITY']==$select){ echo "selected"; } ?>><? echo $row_list['RESPONSIBILITY']; ?></option>

</select>
<input type="submit" name="Submit_The_Data" value="Select" />
</form>
</tr>
<tr>
<td colspan=2 align=center></td>
</tr>
</table>
<table>
<hr>
<p>
</table>
</div>
</div>
</div>




The error i am getting;

Parse error: syntax error, unexpected $end in /var/www/FOX/User_Respon_Creation.php on line 54
Dan Lewis
Member

Registered: 31st Jan 05
Location: Leicestershire
User status: Offline
30th Jan 09 at 13:44   View User's Profile U2U Member Reply With Quote

fixed
Had an extra { on a line

 
New Topic

New Poll

  Related Threads Author Forum Replies Views Last Post
How Much should I get paid... blebo General Chat 21 966
28th Jul 03 at 15:15
by Adam Kindness
 
Anyone use/know anything about Oracle database?? Bram Geek Day 18 1185
16th Mar 04 at 09:09
by Tim
 
Database Application Question: VegasPhil Geek Day 17 578
19th Nov 05 at 13:25
by Gavin
 
Oracle Tutorials... Doug Geek Day 4 226
28th Mar 07 at 21:43
by Sam
 
XML/PHP Laney Geek Day 6 799
26th Apr 07 at 15:03
by Ian
 

Corsa Sport » Message Board » Off Day » Geek Day » SQL - Oracle - PHP 28 database queries in 0.0123749 seconds