Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Programming Contests > PHP Programming Contests

PHP Programming Contests Everything to do with the PHP Programming Contests.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2004-09-28, 06:04 AM
Junior Member
 
Join Date: Sep 2004
Posts: 1
renne
Default

hi all,
i want to download my data for example :
$data=mysql_fetch_array($firstdata);
data of $data will download to .dbf using Php.
how can i do it?

regards,
renne
Reply With Quote
  #2 (permalink)  
Old 2005-02-18, 12:29 PM
Junior Member
 
Join Date: Feb 2005
Posts: 5
humakt
Default

First of all, fetch your MySQL data with something like this :

# Fetching MySQL
$arrayDef=array();
while ($row = mysql_fetch_array($firstdata, MYSQL_ASSOC)){
$arrayDef[]=array($row["value1"],$row["value2"]);
}

Ok. Now I'm not sure if you already have a dbf file that you want to update or no dbf, so you want to create it first. I will assume that you dont have any dbf yet. I will assume also that you have fetched only the good data with your MySQL query and that these 2 datas are "value1" and "value2"...

Something like this should do the trick :


# Creation of dbf
$dbasePath="/yourowndbasepath/file.dbf";
$def=array(
array("value1","N",4,0),
array("value2","C",50)
);
if (!dbase_create($dbasePath, $def)) {
die("Error, can't create the database");
}
# Entering the results in your dbf
$db = dbase_open($dbasePath,2);
if ($db){
reset($arrayDef);
while (list($key,$val)=each($arrayDef)){
dbase_add_record($db,$val);
}
dbase_close($db);
}

For any other thing you want to do with dbf, you can consult PHP doc on dBase Functions.
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.5 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.5 (a popular PHP IDE) and NuCoder 2.0 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:51 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.