Blog
PowerUp

Links

« Insights from the Road: A Week with Power Systems and Linux | Main | Recovery Plans and PTF Currency Vital to Keeping i Relevant »

September 14, 2011

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d83545a5d153ef014e8b68741b970d

Listed below are links to weblogs that reference PHP has Evolved Since My First Open-Source Experience:

Comments

I've had great fun and made plenty of valuable use with the following code Larry shared the how to some time ago and we have used the solution to easily and quickly retrieve data and format it into a CSV (excel) file. It's a little bit of code with lots of Power. In this example a login file is being displayed.

?php
// Laura A. Ubelhor
// Display login file in .CSV format
// Awesome ap to easily connect and create an excel file!

// connect to database
$host = "HOSTIBMI";
$user = 'USERID';
$pass = 'PASSWORD';
$conn = db2_connect ($host,$user,$pass);


// This code will tell the browser that this is a CSV (Excel) file.
header("Content-type: application/octet-stream");
header("Content-disposition: attachment; filename=VRSWebUserIDList".date("Y-m-d").".csv");
header("Pragma: no-cache");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Expires: 0");

//Create Table Headers
echo "User Id, Password, Description, Type, Email Address \n";

// SQL statement - LIBRARY.LOGIN is IBM i library and file name
$query = "SELECT * FROM LIBRARY.LOGIN";

//Execute query
$queryexe = db2_exec($conn, $query) ;

//Fetch results
while(db2_fetch_row($queryexe)) {
$userid = db2_result($queryexe, 'RUSERID');
$password = db2_result($queryexe, 'RPASS');
$description = db2_result($queryexe, 'RDESC');
$type = db2_result($queryexe, 'RTYPE');
$email = db2_result($queryexe, 'REMAIL');

echo "$userid,$password,$description,$type,$email\n";
}
?


*in order to display the code we needed to remove the less than and greater than signs - IBMSystemsMag

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Comments are moderated, and will not appear until the author has approved them.