[PHP-DB] Convert HTML Table to Tab Delimited .TXT file

2004-05-24 Thread dpgirago
Howdy All,

I've PHP / Apache / MySQL running on a Linux machine where a GUI allows an 
administrator to track changes made to computers on our intranet. I've 
been asked to add an 'history' button so that all changes made to one or 
more computers can be put into a table, displayed on client machines 
(windows), then imported into an excel spread sheet.  So far so good. I'm 
querying the dB, retrieving the requested records, then displaying in a 
new window in a table with border set to '0'. The expectation is that the 
admin on a client machine will then copy the table to a text file, then 
import into excel. 

The problem is with the field separator. I tried concatenating a '\t' to 
each field but this didn't behave as expected. Eventually, I concated a 
'|' (bar) character, and this imported with the correct formatting. 
However, now there is this foreign character at the end of  each cell in 
the spread sheet. 

My question is whether there might be a more direct way to get the dB data 
into excel on the client PC (can't imagine how), or if not, how I might 
create a 'tab delimited' file from the HTML table and avoid introducing a 
foreign character as a field separator.

Thanks for reading this long post.

dave 

[PHP-DB] Re: Convert HTML Table to Tab Delimited .TXT file

2004-05-24 Thread Torsten Roehr
[EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
...
 Howdy All,

 I've PHP / Apache / MySQL running on a Linux machine where a GUI allows an
 administrator to track changes made to computers on our intranet. I've
 been asked to add an 'history' button so that all changes made to one or
 more computers can be put into a table, displayed on client machines
 (windows), then imported into an excel spread sheet.  So far so good. I'm
 querying the dB, retrieving the requested records, then displaying in a
 new window in a table with border set to '0'. The expectation is that the
 admin on a client machine will then copy the table to a text file, then
 import into excel.

 The problem is with the field separator. I tried concatenating a '\t' to
 each field but this didn't behave as expected. Eventually, I concated a
 '|' (bar) character, and this imported with the correct formatting.
 However, now there is this foreign character at the end of  each cell in
 the spread sheet.

 My question is whether there might be a more direct way to get the dB data
 into excel on the client PC (can't imagine how), or if not, how I might
 create a 'tab delimited' file from the HTML table and avoid introducing a
 foreign character as a field separator.

A comma seperated values file (.csv) should be readable by Excel. Just put a
; between all values and save it as a text file with .csv extension. I think
you don't need to go all the way via HTML output and copy/paste.

Hope this helps.

Regards, Torsten Roehr

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



Re: [PHP-DB] Re: Convert HTML Table to Tab Delimited .TXT file

2004-05-24 Thread dpgirago
Thanks for responding, Torsten. If I'm understanding your suggestion, then 
what happens where the data from the dB already has a ; (semi-colon) in 
it? Wouldn't this corrupt the import into excel? 

dave

 My question is whether there might be a more direct way to get the dB 
data
 into excel on the client PC (can't imagine how), or if not, how I might
 create a 'tab delimited' file from the HTML table and avoid introducing 
a
 foreign character as a field separator.

 A comma seperated values file (.csv) should be readable by Excel. Just 
put a
 ; between all values and save it as a text file with .csv extension. I 
think
 you don't need to go all the way via HTML output and copy/paste.

 Regards, Torsten Roehr

Re: [PHP-DB] Re: Convert HTML Table to Tab Delimited .TXT file

2004-05-24 Thread Torsten Roehr
[EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
...
 Thanks for responding, Torsten. If I'm understanding your suggestion, then
 what happens where the data from the dB already has a ; (semi-colon) in
 it? Wouldn't this corrupt the import into excel?

This might cause a problem because Excel will start a new row then - this
could also happen with a tab delimiter. At the moment I can't think of a
solution for this. Is it probable that your data contains semicolons?

Regards, Torsten

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



RE: [PHP-DB] Re: Convert HTML Table to Tab Delimited .TXT file

2004-05-24 Thread Daniel . Brunner
You could just use MysqlODBC, and import the data right into the excel 
sheet. 

Just setup a DNS that points to your Mysql server, on the windows box, 
then select Data-Get External data-New Database Query within Excel... 

I'm not sure what the data is, or why you need the data, or what your 
really doing

But that might be in option...


Cheers!!

Dan



-Original Message-
From: roehr [mailto:[EMAIL PROTECTED]
Sent: Monday, May 24, 2004 9:47 AM
To: php-db
Subject: Re: [PHP-DB] Re: Convert HTML Table to Tab Delimited .TXT file


[EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
...
 Thanks for responding, Torsten. If I'm understanding your suggestion, 
then
 what happens where the data from the dB already has a ; (semi-colon) 
in
 it? Wouldn't this corrupt the import into excel?

This might cause a problem because Excel will start a new row then - 
this
could also happen with a tab delimiter. At the moment I can't think of a
solution for this. Is it probable that your data contains semicolons?

Regards, Torsten

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

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



Re: [PHP-DB] Re: Convert HTML Table to Tab Delimited .TXT file

2004-05-24 Thread Torsten Roehr
[EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
...
 Thanks for responding, Torsten. If I'm understanding your suggestion, then
 what happens where the data from the dB already has a ; (semi-colon) in
 it? Wouldn't this corrupt the import into excel?

Please take a look at PEAR's Spreadsheet Excel Writer package:
http://pear.php.net/package/Spreadsheet_Excel_Writer

Of course it's more work than just putting together a string with all values
but it might solve the ; problem.

Regards, Torsten

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



Re: [PHP-DB] Re: Convert HTML Table to Tab Delimited .TXT file

2004-05-24 Thread dpgirago
There definitely are colons, and there is a 'comments' field and 
semi-colons may appear there. However I think I will include a note in the 
help file for the admin to avoid using semi-colons in this field. Seems 
the best solution. And you are right: A .csv is seen as an excel file, so 
opening the audit window then going to file  save as, and making the file 
Audit.csv, or something, avoids having to use the import wizard in excel. 
Saves several steps. Thanks so much! 

dave

 Thanks for responding, Torsten. If I'm understanding your suggestion, 
then
 what happens where the data from the dB already has a ; (semi-colon) in
 it? Wouldn't this corrupt the import into excel?

 This might cause a problem because Excel will start a new row then - 
this
 could also happen with a tab delimiter. At the moment I can't think of a
 solution for this. Is it probable that your data contains semicolons?

 Regards, Torsten

[PHP-DB] Re: Convert HTML Table to Tab Delimited .TXT file

2004-05-24 Thread Chris Berlioz
An easy way to do it (work around) is to dump it as csv or html.  If your
form can output an html table to the browser to show results then all you
need is to include a short instruction on the html form that has all results
in html table that would say something like Save with your browser's 'save
as' button and save it as a HTM file then open it with Excel

Then the user would easily open an HTML file in XLS and do what ever they
want with it (save as XLS, WK*, etc  It gets more complicated if you
want to use formulas in the spreadsheet but if its just raw data this would
be a very easy way to accomplish what  you want.  Hope this helps.

Christian.

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



Re: [PHP-DB] Re: Convert HTML Table to Tab Delimited .TXT file

2004-05-24 Thread dpgirago
Thanks, Christian, and all who responded. I think this is almost exactly 
as it will work. The problem with using some kind of MySQL frontend is 
that this would involve some knowledge of dB's and SQL (can't be certain 
of this), and that it would be additional steps. For example, the GUI 
already allows 1 or more computers to be selected (up to 48, now), and the 
audit history button simply queries the audit_table based upon the same 
selection of computers for all changes made during a specified period. 
Having to create a query for computers 1-7, 11, 15, 16, 24, 31, etc, where 
start date = 'some date' and end date = now() would really be dupliating 
work that the GUI is already doing. 


 An easy way to do it (work around) is to dump it as csv or html.  If 
your
 form can output an html table to the browser to show results then all 
you
 need is to include a short instruction on the html form that has all 
results
 in html table that would say something like Save with your browser's 
'save
 as' button and save it as a HTM file then open it with Excel

 Then the user would easily open an HTML file in XLS and do what ever 
they
 want with it (save as XLS, WK*, etc  It gets more complicated if you
 want to use formulas in the spreadsheet but if its just raw data this 
would
 be a very easy way to accomplish what  you want.  Hope this helps.

 Christian

[PHP-DB] Simple Question... Complex Answer?

2004-05-24 Thread Keith
Dear All,

How do I pass an ADO Recordset by reference to a COM object function in PHP
v4.3.4?

Cheers,
Keith.

ps. I posted a much more long-winded version of this earlier but it was
screwed up in the Newsgroup somehow, (probably my fault).

eg.  My best guess... dies horribly :(

$AComObject = new COM(AServer.AObject);
$AADORecordSet = new VARIANT(VT_DISPATCH | VT_BYREF);

$AComObject-AFunction($AADORecordSet);

while (!$AADORecordSet-EOF)
{
echo $AADORecordSet-Fields[Field1]-value . br;
$AADORecordSet-MoveNext();
}


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



Re: [PHP-DB] Convert HTML Table to Tab Delimited .TXT file

2004-05-24 Thread Mark

--- [EMAIL PROTECTED] wrote:
 Howdy All,
 
 I've PHP / Apache / MySQL running on a Linux machine where a GUI
 allows an 
 administrator to track changes made to computers on our intranet.
 I've 
 been asked to add an 'history' button so that all changes made to
 one or 
 more computers can be put into a table, displayed on client
 machines 
 (windows), then imported into an excel spread sheet.  So far so
 good. I'm 
 querying the dB, retrieving the requested records, then displaying
 in a 
 new window in a table with border set to '0'. The expectation is
 that the 
 admin on a client machine will then copy the table to a text file,
 then 
 import into excel. 
 
 The problem is with the field separator. I tried concatenating a
 '\t' to 
 each field but this didn't behave as expected. Eventually, I
 concated a 
 '|' (bar) character, and this imported with the correct formatting.
 
 However, now there is this foreign character at the end of  each
 cell in 
 the spread sheet. 
 
 My question is whether there might be a more direct way to get the
 dB data 
 into excel on the client PC (can't imagine how), or if not, how I
 might 
 create a 'tab delimited' file from the HTML table and avoid
 introducing a 
 foreign character as a field separator.
 
 Thanks for reading this long post.
 
 dave 

Mmaybe I'm missing something (quite possible), but you can make the
work happen autogically by using http headers.

header(Content-type: application/octet-stream);
header(Content-Disposition: attachment; filename=excelfile.xls);

Replace excelfile.xls with whatever you want the filename to be

Then write out your table as you would normally. the result should be
an excel file either downloaded or opened in the browser, depending
on the browser settings.


=
Mark Weinstock
[EMAIL PROTECTED]
***
You can't demand something as a right unless you are willing to fight to death to 
defend everyone else's right to the same thing.
***




__
Do you Yahoo!?
Yahoo! Domains – Claim yours for only $14.70/year
http://smallbusiness.promotions.yahoo.com/offer 

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



RE: [PHP-DB] undefined function

2004-05-24 Thread Miguel Guirao
OK, I added it!! But it still does work.

BTW, I have four different PHP.ini files in my system, where I can see
which one is using it? I added it to all of them!!

IIS
PHP 4.x
SQL Server

Miguel Guirao
Servicios Datacard
www.SIASA.com.mx

-Mensaje original-
De: Bruno Ferreira [mailto:[EMAIL PROTECTED] 
Enviado el: Viernes, 21 de Mayo de 2004 05:01 p.m.
Para: [EMAIL PROTECTED]
Asunto: Re: [PHP-DB] undefined function

Miguel Guirao wrote:

First, I do not have that line in my php.ini file. In what section
should I add it?
  


Anywhere, but best place as long as organization is concerned would 
be under the Dynamic extensions label.

Bruno Ferreira

PS - You should check the default php.ini that comes with your PHP 
distribution and customize from there.
---
[This E-mail scanned for viruses by Declude Virus]

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

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



Re: [PHP-DB] undefined function

2004-05-24 Thread John W. Holmes
From: Miguel Guirao [EMAIL PROTECTED]

 BTW, I have four different PHP.ini files in my system, where I can see
 which one is using it? I added it to all of them!!

phpinfo() will product a page that shows you what php.ini file PHP is using.
It's in the first block.

---John Holmes...

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



Re: [PHP-DB] Convert HTML Table to Tab Delimited .TXT file

2004-05-24 Thread dpgirago
Wow, thanks. I'm gonna give this a try right now.

dave

Mark Weinstock at [EMAIL PROTECTED] recently wrote...
 Maybe I'm missing something (quite possible), but you can make the
 work happen autogically by using http headers.

 header(Content-type: application/octet-stream);
 header(Content-Disposition: attachment; filename=excelfile.xls);

 Replace excelfile.xls with whatever you want the filename to be

 Then write out your table as you would normally. the result should be
 an excel file either downloaded or opened in the browser, depending
 on the browser settings.

Re: [PHP-DB] Convert HTML Table to Tab Delimited .TXT file

2004-05-24 Thread dpgirago
I've used the header function before for redirection with success, but in 
the current situation I'm not sure where to put the 2 calls to it. I'm 
making the web page on the fly -- querying the dB, writing out the string 
including html tags and the query result, using fopen to create the file, 
then using Javascipt to open a browser window displaying the just created 
page. So far I've either gotten the 'can't send headers, output already 
started' error message, or I've gotten the GUI page itself opened up in 
excel, interesting effect but not the intention ;-)

Does anyone have an idea where to try putting the header calls given the 
above set-up?

Thanks,

dave

 Wow, thanks. I'm gonna give this a try right now.

 dave

 Mark Weinstock at [EMAIL PROTECTED] recently wrote...
 Maybe I'm missing something (quite possible), but you can make the
 work happen autogically by using http headers.

 header(Content-type: application/octet-stream);
 header(Content-Disposition: attachment; filename=excelfile.xls);

 Replace excelfile.xls with whatever you want the filename to be

 Then write out your table as you would normally. the result should be
 an excel file either downloaded or opened in the browser, depending
 on the browser settings.David

RE: [PHP-DB] undefined function

2004-05-24 Thread Miguel Guirao
Thank you everybody!!

I was missing that bloody dll. 

Is working now!!!

Best Regards, and thanks again

Miguel Guirao
Servicios Datacard
www.SIASA.com.mx

-Mensaje original-
De: John W. Holmes [mailto:[EMAIL PROTECTED] 
Enviado el: Lunes, 24 de Mayo de 2004 01:06 p.m.
Para: Miguel Guirao; 'Bruno Ferreira'; [EMAIL PROTECTED]
Asunto: Re: [PHP-DB] undefined function

From: Miguel Guirao [EMAIL PROTECTED]

 BTW, I have four different PHP.ini files in my system, where I can see
 which one is using it? I added it to all of them!!

phpinfo() will product a page that shows you what php.ini file PHP is
using.
It's in the first block.

---John Holmes...

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

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



Re: [PHP-DB] Upload and Display images with Mysql

2004-05-24 Thread Rachel Rodriguez

--- Kpromos [EMAIL PROTECTED] wrote:
 Dears All,
 
 I'm looking for a simple script that will permitme
 to upload images in a mysql database, calling out
 the images with a function from a mysql database
 (calling them from an id variable). I have just
 tried this tutorial

http://www.phpbuilder.com/columns/florian19991014.php3
 but it seems to me that there's nothing to do, as
 images aren't displayed even if all seems to
 function correctly. The doubt is that images are
 stored as bynary files System.Byte[], so it may be
 that I can use the simple img
 src=view.php?id=$id.
 I'm testing all in my Windows PC. Anybody can help
 me? 

I actually remember looking at that PHPBuilder.com
article a few years ago.  Unless you're in a situation
where you are required to store your graphic in the
database, it would be better to store the graphic in
the file system of your operating system, and then
merely capture the path to the file in a column of the
database.  So, for example, if you upload your a
picture called myPhoto.jpg to a path (assuming
you're on UNIX/Linux) called /home/myDirectory, then
the full path to your picture would be:
/home/myDirectory/photos/myPhoto.jpg (without the
quotes, of course).

In the column of your database, INSERT the path to
your photo.  For example:

$sql = INSERT into Table1
(id, photo)
VALUES (null,
'/home/myDirectory/photos/myPhoto.jpg');

Later on, when you want to view your photo, you would
do a SELECT statement on the table to get the path to
your photo and then echo it out to the browser.  For
example, if the id of your photo was 1:

$query = SELECT Table1.photo
  WHERE Table1.id = '1';

$result = mysql_query($query, $connection_info_here)
or die(Couldn't pull photo.);

while ($row = mysql_fetch_array($result))
{
$photo = $row['photo'];
}

To display the photo, as you already know, just use
img tags and echo statement:

img src=?php echo $photo; ?

I have not included any error checking.  This is just
a skeleton way of doing it.

The PHP manual does a good job of explaining file
uploads which you'll be required to do for uploads
regardless of where you store the graphic (either in
the file system or in the database).

http://us4.php.net/features.file-upload


=
~Rachel




__
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 

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



Re: [PHP-DB] Convert HTML Table to Tab Delimited .TXT file

2004-05-24 Thread Mark

--- [EMAIL PROTECTED] wrote:
 I've used the header function before for redirection with success,
 but in 
 the current situation I'm not sure where to put the 2 calls to it.
 I'm 
 making the web page on the fly -- querying the dB, writing out the
 string 
 including html tags and the query result, using fopen to create the
 file, 
 then using Javascipt to open a browser window displaying the just
 created 
 page. So far I've either gotten the 'can't send headers, output
 already 
 started' error message, or I've gotten the GUI page itself opened
 up in 
 excel, interesting effect but not the intention ;-)
 
 Does anyone have an idea where to try putting the header calls
 given the 
 above set-up?

If you're calling a PHP page from Javascript, then you should put the
headers before anything is sent to the browser on that PHP page. For
example,

?php
header(Content-type: application/octet-stream);
header(Content-Disposition: attachment; filename=excelfile.xls);
?
TABLE
TRTDHeader 1/TDTDHeader 2/TD/TR
TRTDR1C1/TDTDR1C2/TD/TR
TRTDR2C1/TDTDR2C2/TD/TR
/TABLE

The table creation can all be done in PHP as well.

If you're building the page using document.write(), things might be
more complicated...

 Thanks,
 
 dave
 
  Wow, thanks. I'm gonna give this a try right now.
 
  dave
 
  Mark Weinstock at [EMAIL PROTECTED] recently wrote...
  Maybe I'm missing something (quite possible), but you can make
 the
  work happen autogically by using http headers.
 
  header(Content-type: application/octet-stream);
  header(Content-Disposition: attachment;
 filename=excelfile.xls);
 
  Replace excelfile.xls with whatever you want the filename to be
 
  Then write out your table as you would normally. the result
 should be
  an excel file either downloaded or opened in the browser,
 depending
  on the browser settings.David


=
Mark Weinstock
[EMAIL PROTECTED]
***
You can't demand something as a right unless you are willing to fight to death to 
defend everyone else's right to the same thing.
***




__
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 

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