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.
|