PHP ODBC return all records -
i started using php oracle using odbc commands. used odbc_exec query database, seems work.
i trying print dataset text file. able write text file, reason, able 1 record/row table.
one query in particular returns on 100 records. able print 100 records in text file.
i have researched on web, , have come close getting work. in fact, can print records web page. can't of records text file.
please see code below , advise missing.
<?php $voyage = $_post['voyage']; $query = "select * voyagetable voyage = '".$voyage."'"; $result = odbc_exec($connect, $query); while($row = odbc_fetch_array($result)) // have tried odbc_fetch_row { $fullname = odbc_result($result, 1); } $datefile = "cmdu-".$voyage."-".date('dmy').".txt"; $datastring = $fullname . "\n"; $fwrite = fopen($datefile, "a"); $wrote = fwrite($fwrite, $datastring); fclose($fwrite); ?>
i know close getting this.
i have altered while loop numerous times. tried well:
<?php while(odbc_fetch_array($result)) // ... ?>
please help. unsuccessful well.
instead of
$fullname = odbc_result($result, 1);
you need either echo out this:
echo odbc_result($result, 1);
or store result in array this:
$fullname[] = odbc_result($result, 1);
just storing value of each row in $fullname variable overwrite value , give last value last row in result set.
expanding on ಠ_ಠ's comment.
Comments
Post a Comment