Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2000121

Re: [PHP-DB] dbase_ commands dont work From: Miles Thompson (milesthompson <email protected>)
Date: 12/14/00

Visual FoxPro tables are different creatures and don't behave like dBase or FoxPro 2.x tables. If what follows is basic info to VFP people,
please forgive me. I'm also doing this off the top of my head, so if I've slipped up with some minor details, a little slack would be
appreciated.

Visual FoxPro introduced the concept of a database containing tables to the dBase world with VFP 3.0 in 1995. It wasn't done in the way we may
be familiar with, like Access, PostgreSQL, SQL server et. al., where the database is essentially one massive file.

VFP organizes a database as a database container (.DBC extension) and tables (.DBF extension), all as separate files. The .DBC contains
definitions, triggers, constraints, views etc. and knowledge of which .DBF files make up the database.

DBF files which are part of a database are uniquely identified by a flag in their header- byte 0 is 0x30. To existing programs which may attempt
to use them, including FoxPro 2.x, THEY DO NOT LOOK LIKE .DBF's. I don't recommend monkeying around with the header, although it can be done
with judicious use of fopen() and fput(). If the header is changed, they become invisible to the .DBC.

To use VFP .DBF's, use "COPY TO filename TYPE FOX2X" or EXPORT the data from within VFP and use the exported files. Alternately you could use
ODBC.

I hope you find this helpful and that you'll succeed in bringing in your information.

- Miles Thompson

Abdul Kadir wrote:

> Frank is right. I have tested a program like below to read 3 Visual FoxPro's tables. (but I am sorry because the example is in Indonesian).
>
> Regards,
> Abdul Kadir
>
> <HTML>
> <HEAD>
> <TITLE>Daftar Nilai</TITLE>
> </HEAD>
> <BODY>
>
> <BODY LINK="#0000ff" VLINK="#800080" BACKGROUND="Image3.jpg">
> <?php
> //$no_mhs = "S71005 ";
> $no_mhs = trim($no_mhs);
>
> $panjang = strlen($no_mhs);
>
> if ( !( ($panjang == 6) || ($panjang == 9)) )
> {
> printf("Nomor mahasiswa salah(1)<BR>\n");
> return;
> }
>
> if ($panjang == 6)
> {
> if (! ((substr($no_mhs,0,1)=='S') || (substr($no_mhs,0,1)=='D')))
> {
> printf("Nomor mahasiswa salah(2)<BR>\n");
> return;
> }
>
> $no_mhs = sprintf("%s ",$no_mhs);
> }
>
> $db_pribmhs = dbase_open("pribmhs.dbf", 0);
> $db_mahasis = dbase_open("mahasis.dbf", 0);
> $db_nilai = dbase_open("nilai.dbf", 0);
>
> if (($db_pribmhs == False) || ($db_mahasis == False) || ($db_nilai == False))
> {
> printf("Maaf. untuk sementara belum berfungsi<BR>\n");
> return ;
> }
>
> // Cek Status
> $num_rec = dbase_numrecords($db_mahasis);
> $ketemu = False;
> for($index = 1; $index <= $num_rec; $index++)
> {
> $record = dbase_get_record($db_mahasis, $index);
> if ($record[0] == $no_mhs)
> {
> if (($record[9]=='B') && ($record[6]=='2'))
> {
> $ketemu = True;
> }
>
> break;
> }
>
> }
>
> if ($ketemu == False)
> {
> print("Akses data tidak diperkenankan<BR>\n");
> return;
> }
> ?>
>
> <?php
>
> // Cek Nama
> $num_rec = dbase_numrecords($db_pribmhs);
> $ketemu = False;
> for($index = 1; $index <= $num_rec; $index++)
> {
> $record = dbase_get_record($db_pribmhs, $index);
> if ($record[0] == $no_mhs)
> {
> print("Nama : $record[1]<BR>\n");
> $ketemu = True;
> break;
> }
>
> }
>
> if ($ketemu == False)
> {
> print("Nomor mahasiswa ini tidak ditemukan<BR>\n");
> return;
> }
>
> flush();
>
> $current_date = getdate(time());
>
> printf("DAFTAR NILAI Per Tanggal %d/%d/%d<BR><BR>\n",
> $current_date["mday"],
> $current_date["mon"],
> $current_date["year"]);
>
> // Cek Nilai
> $num_rec = dbase_numrecords($db_nilai);
> $nomor = 0;
>
> for($index = 1; $index <= $num_rec; $index++)
> {
> $record = dbase_get_record($db_nilai, $index);
> if ($record[0] == $no_mhs)
> {
> $nomor++;
> $mk[$nomor] = $record[1];
> $nilai[$nomor] = $record[2];
> }
> }
>
> print("<TABLE BORDER=\"1\">\n");
> if ($nomor > 0)
> {
> print("<TD>");
> print("NO.");
> print("</TD>");
> print("<TD>");
> print("KD. MATAKULIAH");
> print("</TD>");
> print("<TD>");
> print("NILAI");
> print("</TD>");
>
> print("</TR>\n");
>
> }
>
> for ($index = 1; $index <= $nomor; $index++)
> {
> print("<TD>");
> print($index);
> print("</TD>");
> print("<TD>");
> print($mk[$index]);
> print("</TD>");
> print("<TD>");
> print($nilai[$index]);
> print("</TD>");
>
> print("</TR>\n");
> }
>
> print("</TABLE>\n");
> if ($nomor == 0)
> {
> print("Nilai untuk mahasiswa ini tidak ditemukan<BR>\n");
> return;
> }
>
> printf("*** end <BR>\n");
>
> dbase_close($db_pribmhs);
> dbase_close($db_mahasis);
> dbase_close($db_nilai);
>
> ?>
>
> </BODY>
> </HTML>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>