Help needed PHP with Excel database

Help needed PHP with Excel database

am 31.05.2008 18:35:54 von jdp

Hi I am a PHP beginner and using "Namo Webeditor" trial version in
order

to access an Excel file via ODBC...and I get no result
Namo generates the following code:
=================================
$a_startrow = $startrow;
$a_maxrows = $maxrows;
require('wed_php_odbc.inc');
?>

Sans titre


alink="red">
$w_disprows = 10;
$w_sqlstr = "SELECT Feuli1$_FilterDatabase.Country,
Feuli1$_FilterDatabase.Customer Name, Feuli1$_FilterDatabase.Model,
Feuli1$_FilterDatabase.Description, Feuli1$_FilterDatabase.Order
Number,
Feuli1$_FilterDatabase.Quantity FROM Feuli1$_FilterDatabase";
wed_read_list_process ("trydb", "", "", $w_sqlstr, $w_record,
$w_disprows, $a_startrow, $a_maxrows, $w_rows);
?>










for ($w_i = 0; $w_i < $w_rows; $w_i++) {
$f_Feuli1__FilterDatabase_Country = $w_record[$w_i][0];
$f_Feuli1__FilterDatabase_Customer_Name = $w_record[$w_i][1];
$f_Feuli1__FilterDatabase_Model = $w_record[$w_i][2];
$f_Feuli1__FilterDatabase_Description = $w_record[$w_i][3];
$f_Feuli1__FilterDatabase_Order_Number = $w_record[$w_i][4];
$f_Feuli1__FilterDatabase_Quantity = $w_record[$w_i][5];
?>







}

?>


Feuli1$_FilterDatabase.Country Feuli1$_FilterDatabase.Customer Name Feuli1$_FilterDatabase.Model Feuli1$_FilterDatabase.Description Feuli1$_FilterDatabase.Order Number Feuli1$_FilterDatabase.Quantity
wed_write($f_Feuli1__FilterDatabase_Country);
?>

wed_write($f_Feuli1__FilterDatabase_Customer_Name);
?>
wed_write($f_Feuli1__FilterDatabase_Model);
?>
wed_write($f_Feuli1__FilterDatabase_Description);
?>
wed_write($f_Feuli1__FilterDatabase_Order_Number);
?>
wed_write($f_Feuli1__FilterDatabase_Quantity);
?>
wed_list_move_page(10,
$w_disprows, $a_startrow, $a_maxrows, "");
?>

 




=======================================
where wed_php_odbc.inc contains:
=======================================
function wed_read_list_process($servername, $userid, $passwd, $sqlstr,
&$record, $disprows, $startrow, &$maxrows, &$rows)
{
$connect = odbc_connect($servername, $userid, $passwd);
$cursor = odbc_exec($connect, $sqlstr);
// skip pre list
for ($i = 0; $i < $startrow; $i++) {
odbc_fetch_into($cursor, /*$i,*/ &$row);
}
// fetch list (max disprows rows)
for ($rows = 0; ($rows < $disprows) && odbc_fetch_into($cursor,
/*$startrow + $rows,*/ &$row); $rows++) {
$record[$rows] = $row;
}
// determine maxrows
if ($maxrows == 0) {
for ($maxrows = $startrow + $rows; odbc_fetch_into($cursor,
/*$maxrows,*/ &$row); $maxrows++) {
;
}
}
odbc_close($connect);
}
=======================================
and
=======================================
function wed_write($value)
{
if ($value != null) {
$length = strlen($value);

$pos1 = strpos($value, "#");

if ($pos1 !== FALSE) {
$pos2 = strpos($value, "#", $pos1+1);

if ($length == $pos2 + 1) {
$link_str = substr($value, $pos1 + 1, $pos2 - $pos1 - 1);
if ($pos1 == 0)
$text_str = substr($value, $pos1 + 1, $pos2 - $pos1 - 1);
else
$text_str = substr($value, 0, $pos1);
$value = sprintf("", $link_str,
$text_str);
}
}

$w_value = str_replace("\n", "
", $value);
}
else {
$w_value = " ";
}
echo($w_value);
}
=======================================

I never get the expected value.
My excel file is :
=======================================
Customer Name Model Description Order Number Quantity
CustUK1 Pan1 Pan UK001 2
CustUK2 Fork1 Fork UK002 5
CustFR knife1 knife FR001 15
=======================================
and I get:

=======================================
Feuli1$_FilterDatabase.Country Feuli1$_FilterDatabase.Customer Name
Feuli1$_FilterDatabase.Model Feuli1$_FilterDatabase.Description
Feuli1$_FilterDatabase.Order Number Feuli1$_FilterDatabase.Quantity
[ ]
where Feuli1 is the name of the spreadsheet
=======================================
I am not sure that PHP connects to the file and read it althoough Namo
has regognized the name of the fields.

Anybody can help ?



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php