OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 29 Sep 2003 23:33:36 -0000 Issue 2326

php-general-digest-helplists.php.net
Date: Mon Sep 29 2003 - 18:33:36 CDT


php-general Digest 29 Sep 2003 23:33:36 -0000 Issue 2326

Topics (messages 164216 through 164320):

Re: Compare dates
        164216 by: Blue Prawn
        164223 by: Leif K-Brooks

php and checkboxes.
        164217 by: Angelo Zanetti
        164218 by: Marek Kilimajer
        164219 by: Angelo Zanetti
        164221 by: Eugene Lee
        164238 by: CPT John W. Holmes

regexp: 'a correctly parenthesized substring advanced'
        164220 by: Jaaboo

PHP & Rading excel files
        164222 by: BENARD Jean-philippe
        164257 by: Tom Rogers
        164311 by: Jackson Miller

Re: General .htaccess question
        164224 by: Marek Kilimajer

nonblocking socket causes 100% cpu usage
        164225 by: Joe

MerlinWork PHP Framework
        164226 by: Fabrizio Balliano
        164227 by: chris.neale.somerfield.co.uk

Re: Resource Limits
        164228 by: Donald Tyler
        164235 by: Eugene Lee

Re: How to "smart refresh" php section using iframe?
        164229 by: Donald Tyler
        164236 by: Jay Blanchard

Re: Please visit my php program
        164230 by: Nelson Rodríguez-Peña Alarcón

Re: PHP coders spare time [OT}
        164231 by: Jay Blanchard
        164233 by: Jay Blanchard
        164234 by: chris.neale.somerfield.co.uk
        164237 by: CPT John W. Holmes
        164271 by: Chris W. Parker
        164274 by: Jon Kriek

search a string backwards - like reversed stripos
        164232 by: Chris Widmer
        164251 by: Curt Zirzow

RE : [PHP] PHP & Rading excel files
        164239 by: BENARD Jean-philippe
        164241 by: Marek Kilimajer
        164242 by: chris.neale.somerfield.co.uk
        164243 by: chris.neale.somerfield.co.uk

Export resultset
        164240 by: DPCMA Metalito
        164245 by: Marek Kilimajer
        164246 by: CPT John W. Holmes

Re: php & xvfb gives xauth command not found
        164244 by: Ray Hunter
        164247 by: Ray Hunter

Re: add element to an array
        164248 by: Chris Sherwood

Re: gettext: changed .mo file, caching issue
        164249 by: daniel hahler

Re: Add element
        164250 by: Chris Sherwood

Evolution syncing
        164252 by: David Norman
        164313 by: Jackson Miller

How many Mondays in a month?
        164253 by: Phil Dowson
        164254 by: Curt Zirzow
        164255 by: Greg Wiley
        164268 by: Phil Dowson
        164273 by: Greg Wiley
        164281 by: Burhan Khalid
        164282 by: Greg Wiley

A _post question I guess
        164256 by: John Taylor-Johnston
        164258 by: Brad Pauly
        164259 by: Tom Rogers
        164260 by: John Taylor-Johnston
        164261 by: Brad Pauly
        164263 by: John Taylor-Johnston

Does the AOL browser break any standards?
        164262 by: Dan Anderson
        164264 by: Chris Shiflett
        164265 by: Dan Anderson
        164266 by: Larry Rosenman
        164267 by: Dan Anderson
        164269 by: Jay Blanchard
        164270 by: Dan Anderson
        164272 by: Jason Wong
        164276 by: Dan Anderson
        164278 by: Kevin Bruce
        164280 by: Jason Wong

captcha WAS Please visit my php program
        164275 by: Chris W. Parker
        164277 by: Chris Shiflett
        164279 by: Chris W. Parker
        164283 by: Roger B.A. Klorese

Strange comportment ...
        164284 by: alain.cabinfo.com

Central authentication for multiple sites
        164285 by: Fraser Campbell
        164286 by: Kevin Bruce
        164288 by: Kevin Stone
        164289 by: Marek Kilimajer
        164292 by: Vail, Warren
        164293 by: Fraser Campbell
        164295 by: CPT John W. Holmes
        164297 by: Fraser Campbell
        164299 by: Marek Kilimajer
        164300 by: CPT John W. Holmes

Cleaning up my messy code
        164287 by: Chris
        164290 by: Burhan Khalid
        164294 by: Brent Baisley
        164296 by: Jay Blanchard
        164298 by: CPT John W. Holmes
        164301 by: andu
        164303 by: Robert Cummings
        164304 by: Vail, Warren
        164307 by: Robert Cummings
        164308 by: Vail, Warren
        164312 by: Chris
        164314 by: Robert Cummings
        164317 by: Vail, Warren
        164318 by: Curt Zirzow
        164319 by: Chris
        164320 by: Robert Cummings

download queue
        164291 by: Alex

control M from export file
        164302 by: Ed Kwok
        164305 by: Chris Shiflett
        164306 by: Eugene Lee
        164316 by: Curt Zirzow

Problems with imagecreatefromjpeg ?
        164309 by: Darren Gamble

Initial Value for Input Box
        164310 by: Matt Palermo
        164315 by: Eugene Lee

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


> How can I compare two dates with PHP, to see if one date occurred before
> the other?

probably not the best way but:

if the date is formated like this 20030929 (today) 20030928 (yesterday)
I think it is quite easy:
if ( (int)$today > (int)$yesterday )
or perhaps like this:
if ( strcmp($today, $yesterday) )

if you have to change the format, you can use :
http://www.php.net/manual/en/function.preg-replace.php

attached mail follows:


Shaun wrote:

>How can I compare two dates with PHP, to see if one date occurred before the
>other?
>
>
Convert them to a timestamps (strtotime()), then just compare them:

$date1 = 'september 10th 2003';
$date2 = 'september 20th 2003';

$date1_ts = strtotime($date1);
$date2_ts = strtotime($date2);

if($date1_ts < $date2_ts){
     echo 'Date 1 is before date 2.';
}else{
     echo 'Date 2 is before date 1.';
}

--
The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.

attached mail follows:


Hi all

I have a table that is populated from a database which gets the IDs of the
records from a php array.Every row in the table has a checkbox next to the
actual record, what I want to do is to allow the user to select the records
they want to remove by clicking the checkbox(es) and then click a button to
submit the form.

so how do I remove these records? do I:

-do I do an array_diff and then just select the records that are remaining?

this to me seems the most logical.

tia

attached mail follows:


Simple:
foreach($_POST['del_checkboxes'] as $id) {
        $sql="delete from table where id='$id'";
}

Checkboxes are created using
<input .... name="del_checkboxes" value="<?= $id ?>">

Angelo Zanetti wrote:

> Hi all
>
> I have a table that is populated from a database which gets the IDs of the
> records from a php array.Every row in the table has a checkbox next to the
> actual record, what I want to do is to allow the user to select the records
> they want to remove by clicking the checkbox(es) and then click a button to
> submit the form.
>
> so how do I remove these records? do I:
>
> -do I do an array_diff and then just select the records that are remaining?
>
> this to me seems the most logical.
>
> tia
>

attached mail follows:


Hi Marek,

I dont actually want to delete the record from the database, perhaps I wasnt
very clear in my explanation, but I just need to remove that entry from the
table.

kinda like when deleting mail from your web email account like hotmail.

-----Original Message-----
From: Marek Kilimajer [mailto:kilimajerwebglobe.sk]
Sent: Monday, September 29, 2003 1:36 PM
To: angelozlogic.co.za
Cc: Php-GeneralLists.Php.Net
Subject: Re: [PHP] php and checkboxes.

Simple:
foreach($_POST['del_checkboxes'] as $id) {
        $sql="delete from table where id='$id'";
}

Checkboxes are created using
<input .... name="del_checkboxes" value="<?= $id ?>">

Angelo Zanetti wrote:

> Hi all
>
> I have a table that is populated from a database which gets the IDs of the
> records from a php array.Every row in the table has a checkbox next to the
> actual record, what I want to do is to allow the user to select the
records
> they want to remove by clicking the checkbox(es) and then click a button
to
> submit the form.
>
> so how do I remove these records? do I:
>
> -do I do an array_diff and then just select the records that are
remaining?
>
> this to me seems the most logical.
>
> tia
>

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

attached mail follows:


On Mon, Sep 29, 2003 at 01:43:08PM +0200, Angelo Zanetti wrote:
:
: Marek Kilimajer suggested:
: >
: > Angelo Zanetti wrote:
: > >
: > > I have a table that is populated from a database which gets the
: > > IDs of the records from a php array.Every row in the table has a
: > > checkbox next to the actual record, what I want to do is to allow
: > > the user to select the records they want to remove by clicking the
: > > checkbox(es) and then click a button to submit the form.
: > >
: > > so how do I remove these records?
: >
: > Simple:
: > foreach($_POST['del_checkboxes'] as $id) {
: > $sql="delete from table where id='$id'";
: > }
:
: I dont actually want to delete the record from the database, perhaps I
: wasnt very clear in my explanation, but I just need to remove that
: entry from the table.

To remove a record is to delete a row. Same thing. When you say
"entry", do you mean "record" or "row"? Or do you mean something else?

If you want to change "one or more columns of a row" (this can also
be stated as "one or more fields of a record"), use the SQL command
"UPDATE <table> SET col1=expr1,col1=expr2,... WHERE ID=id_expr".

attached mail follows:


From: "Angelo Zanetti" <binc2ctech.ac.za>

> I dont actually want to delete the record from the database, perhaps I
wasnt
> very clear in my explanation, but I just need to remove that entry from
the
> table.
>
> kinda like when deleting mail from your web email account like hotmail.

Same idea...

<input type="checkbox" name="remove[]" value="xx">

Where xx is the ID of that entry/row.

Then, to select whatever is in the table, minus whatever was selected...

$list = implode(',',$_POST['remove']);
$query = "SELECT * FROM Table WHERE id NOT IN ($list)";

If you want this "list" to propagate each time things are selected, then
you'll have to "remember" what's been selected using the session or hidden
elements.

---John Holmes...

attached mail follows:


Hi ,
this is my regex for php to extract php-function-calls from source. It now
works for strings like:
func1($param,"abc")
func1($param1,func2($param2,"abc"))

but if i try to catch

func1($param1,"(c) by ARTADA for example")´, func2($param2,"786"))

 it fails because of the paranthesis between the " " .
hás anyone an idea of how i can ignore paranthesis between the " " for
correct
counting the closing paranthesis

here is my current regex:
/([a-zA-Z]\w*?)\s*(\(((?>.*?)|.*?(?R)*)\))+/msi

this looks a little stupid but it catches all function calls within an
codeblock without the need of an function delimiter like ; in php
I need the functionality for a templating system where the syntax for the
templating system would be simpler and resitricted php code that i complete
to full working php code.

thax a lot for any suggestion

attached mail follows:


Hi !

        It's possible to export data to excel (csv, xml, PEAR excel file
writing, ...) but is it possible to import data from excel ? (i.e.: I
want to get the data which is in Cell "A1" of sheet "Toto" in the posted
.xls file).

Thanks in advance.

            (o_ BENARD Jean-Philippe - Consultant STERIA Infogérance
(o_ (o_ //\ RENAULT DTSI/ODPS/RD * ALO * API : MLB 02C 1 14
(/)_ (\)_ V_/_ 2 Av du vieil étang * 78181 MONTIGNY-LE-BRETONNEUX
                       Tél : +33 1-30-03-47-83 * Fax : +33 1-30-03-42-10

attached mail follows:


Hi,

Monday, September 29, 2003, 10:10:43 PM, you wrote:
BJp> Hi !

BJp> It's possible to export data to excel (csv, xml, PEAR excel file
BJp> writing, ...) but is it possible to import data from excel ? (i.e.: I
BJp> want to get the data which is in Cell "A1" of sheet "Toto" in the posted
BJp> .xls file).

BJp> Thanks in advance.

I have been working on a php excel reader class which is nearing a usable state,
At the moment it just displays the sheets but it should be easy to extract the
cell data. You can test it here http://fred.kwikin.com/xl/
There are still a few display bugs to iron out but it will be a good start :)
It will only work with ole2 xls files at the moment.
Let me know if it will help and I will send you the files.

--
regards,
Tom

attached mail follows:


On Monday 29 September 2003 7:10, BENARD Jean-philippe wrote:
> Hi !
>
> It's possible to export data to excel (csv, xml, PEAR excel file
> writing, ...) but is it possible to import data from excel ? (i.e.: I
> want to get the data which is in Cell "A1" of sheet "Toto" in the posted
> .xls file).

The short answer is "not yet".

The PEAR::Spreadsheet_Excel_Writer folks are basically porting over a CPAN
perl module. There is currently another perl module for reading Excel files.
I _think_ the folks working on the PEAR module will do this one next.

I have used the perl module to write a xls2csv.pl script that I exec() from
within PHP. That allows my web app to accept Excel files for imports.

Surprisingly, even 65,000 rows get converted to csv pretty quick.

Now, if you want all the functions and such then you will want to look deeper
into the Perl module (or be the one to port it to PHP).

-Jackson

>
> Thanks in advance.
>
> (o_ BENARD Jean-Philippe - Consultant STERIA Infogérance
> (o_ (o_ //\ RENAULT DTSI/ODPS/RD * ALO * API : MLB 02C 1 14
> (/)_ (\)_ V_/_ 2 Av du vieil étang * 78181 MONTIGNY-LE-BRETONNEUX
> Tél : +33 1-30-03-47-83 * Fax : +33 1-30-03-42-10

--
jackson miller
 
cold feet creative
615.321.3300 / 800.595.4401
jacksoncoldfeetcreative.com
 
 
cold feet presents Emma
the world's easiest email marketing
Learn more  http://www.myemma.com

attached mail follows:


This should not bother you. If you get enough load then .htaccess file
is cached in the memory. If your load is moderate then it does not make
much difference. And since your webhost enabled this feature they should
know what they are doing.

Mike Brum wrote:

> I think I know the answer to this, but want some confirmation from someone a
> bit more knowledgable about Apache and .htaccess files.
>
> My webhost has the default 404 page set to 404.html. For the sake of
> consistancy on a number of levels, I prefer a PHP file for this (404.php).
> So to do this, I created a basic .htaccess file for this very purpose and it
> sits in the root dir.
>
> Now, does this .htaccess file get read for EVERY resource request on my site
> - even when the page is found?
>
> Aside from a META redirect from 404.html to 404.php, is there a less
> server-intensive way to set my 404 in Apache when I don't have root access?
>
> Thanks
>
> -M
>

attached mail follows:


I have a commandline php script, which opens a nonblocking socket to
a server. Inside the message loop, where it polls the socket to determine
whether there is any data to read/write, I've been running into problems,
where the application takes as much CPU time as it can (80%, 90%,
sometimes 99%, etc)... Normally, using socket_select() with a timeout
should allow allow it to poll the socket without using all the cpu time,
but it isn't working. I've tried with timeouts of 15ms, 100ms, 200ms,
500ms, 1sec, and it's still using 100% cpu time. Even adding sleep() and
usleep() calls will not relieve the system load that the script causes.
For now, I've fixed the problem temporarily by not setting the socket in
nonblocking mode (so it blocks when reading), but the reason I need to use
nonblocking is that I'm adding more to it that will require that the
script can respond to events *between* reading from the socket. Can
anyone explain why socket_select and other timeout function calls would
still cause it to use 100% cpu time? If it makes a difference, the script
is on gentoo linux, and it includes a fork() call, to fork into the
background (though this shouldn't make a difference).

Is it possible that socket_select() ignores the timeout values, if the
sockets are nonblocking? Or would I be able to use socket_select() on a
blocking socket, to simulate the effect of a nonblocking socket (so that I
would only call socket_read() IF socket_select() indicates that there is
data waiting.)

Thanks
Joe

attached mail follows:


Hi to all,
I'd like to present show you a PHP framework written by my company:
MerlinWork.

Its built with the concept of allowing developers to build a web
application like they would do with a client application developing
environment.

The result is a stateful application, managed by events.
Developer has a set of widget to use, like tables, fields, buttons etc.

It's distribuited under the GPL licence and it's available at
http://merlinwork.sourceforge.net.

An interactive (easy development) demo is available at
http://merlinwork-demo.crealabs.it.

Its core features are:
- strongly object oriented
- stateful
- many usable and customizable objects
- self installing
- no database required

Feel free to download and try it and make me know what do you think
about it.
Regards

--
Fabrizio Balliano
________

CREALABS
Viale dei Mughetti, 13/A - 10151 Torino - Italy
Tel. +39-011-735645 - Fax +39-011-735645
http://www.crealabs.it - mailto:fabrizio.ballianocrealabs.it

attached mail follows:


I like I like.

Look like it might cut a lot of tedious leg-work out.

Regards

Chris

-----Original Message-----
From: Fabrizio Balliano [mailto:fabrizio.ballianocrealabs.it]
Sent: 29 September 2003 12:37
To: php-generallists.php.net
Subject: [PHP] MerlinWork PHP Framework

Hi to all,
I'd like to present show you a PHP framework written by my company:
MerlinWork.

Its built with the concept of allowing developers to build a web
application like they would do with a client application developing
environment.

The result is a stateful application, managed by events.
Developer has a set of widget to use, like tables, fields, buttons etc.

It's distribuited under the GPL licence and it's available at
http://merlinwork.sourceforge.net.

An interactive (easy development) demo is available at
http://merlinwork-demo.crealabs.it.

Its core features are:
- strongly object oriented
- stateful
- many usable and customizable objects
- self installing
- no database required

Feel free to download and try it and make me know what do you think
about it.
Regards

--
Fabrizio Balliano
________

CREALABS
Viale dei Mughetti, 13/A - 10151 Torino - Italy
Tel. +39-011-735645 - Fax +39-011-735645
http://www.crealabs.it - mailto:fabrizio.ballianocrealabs.it

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
 
If you are not the intended recipient of this e-mail, please preserve the
confidentiality of it and advise the sender immediately of any error in
transmission. Any disclosure, copying, distribution or action taken, or
omitted to be taken, by an unauthorised recipient in reliance upon the
contents of this e-mail is prohibited. Somerfield cannot accept liability
for any damage which you may sustain as a result of software viruses so
please carry out your own virus checks before opening an attachment. In
replying to this e-mail you are granting the right for that reply to be
forwarded to any other individual within the business and also to be read by
others. Any views expressed by an individual within this message do not
necessarily reflect the views of Somerfield. Somerfield reserves the right
to intercept, monitor and record communications for lawful business
purposes.

attached mail follows:


Just incase you weren't aware. You can change the Max execution time
during the script with:

set_time_limit(Milliseconds);

-----Original Message-----
From: Decapode Azur [mailto:blue_prawntuxfamily.org]
Sent: Saturday, September 27, 2003 5:51 AM
To: php-generallists.php.net
Subject: [PHP] Resource Limits

hi the list,

How can I get the values of 'max_execution_time', 'max_input_time' and
'memory_limit' from my php script ?

thanks

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

attached mail follows:


On Mon, Sep 29, 2003 at 07:49:40AM -0500, Donald Tyler wrote:
:
: Decapode Azur asked:
: >
: > How can I get the values of 'max_execution_time', 'max_input_time' and
: > 'memory_limit' from my php script ?
:
: Just incase you weren't aware. You can change the Max execution time
: during the script with:
:
: set_time_limit(Milliseconds);

That should be seconds, not milliseconds. :-)

        http://www.php.net/manual/en/function.set-time-limit.php

attached mail follows:


This is not possible with PHP alone. You need to use some client side
code such as JavaScript or Flash.

I would recommend JavaScript. It would be pretty easy to accomplish what
you are talking about with that.

Grab yourself a copy of "JavaScript the Definitive Guide" by Orielly.
It's pretty comprehensive.

-----Original Message-----
From: ascll [mailto:ascllyahoo.com]
Sent: Saturday, September 27, 2003 1:44 AM
To: php-generallists.php.net
Subject: [PHP] How to "smart refresh" php section using iframe?

Greetings,

I'm newbie in php and I would like to develop a .php page that
constantly
retrieves data from MySQL database, but I having difficulties to doing
so.
Please show me the complete code, if possible.

Thanks in advance.

===== index.php =====
<html>
<body>
<table>

<!--
// SECTION A
// =========
// Load one only, no need to refresh
-->
<tr>
  <td>Column1</td>
  <td>Column2</td>
  <td>Column3</td>
  <td>Column4</td>
  <td>Column5</td>
</tr>

<!--
// SECTION B
// =========
// Using .php to retrieve data from MySQL database (no problem)
// together with "iframe" (I don't know how to configure <iframe>)
// and also use "javascript" to auto refresh this section every 1-second
(SECTION B ONLY)
// since the data show on section B would keep on changing (I don't know
the
codes)
-->
<tr>
  <td> . $Column1 . </td>
  <td> . $Column2 . </td>
  <td> . $Column3 . </td>
  <td> . $Column4 . </td>
  <td> . $Column5 . </td>
</tr>

<!--
// SECTION C
// =========
// Auto refresh this section every 30-second (SECTION C ONLY and I don't
know the codes)
-->
<tr>
  <td> . $Column1 . </td>
  <td> . $Column2 . </td>
  <td> . $Column3 . </td>
  <td> . $Column4 . </td>
  <td> . $Column5 . </td>
</tr>

<!--
// SECTION D
// =========
// Load one only, no need to refresh
-->
<tr>
  <td>End of Record</td>
</tr>

</table>
</body>
</html>
===== index.php =====

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

attached mail follows:


[snip]
This is not possible with PHP alone. You need to use some client side
code such as JavaScript or Flash.
[/snip]

I think that with a combination (I have not tested this) of ob_start,
ob_flush(), sleep(), and header() that this could be accomplished.

ob_start();
....
gather output
....
ob_flush(); //flush output
sleep(); //waiting to refresh
header($PHP_SELF); exit();

Again, this is not tested, but my very foggy Monday morning brain says
this should work, no?

attached mail follows:


Hi Ryan,

Ryan A wrote:
>Hey everyone,
>Please visit my captcha program here and tell me if its good

here I got the following error (or notice):

Notice: Undefined index: TheSecretWord in
/usr163/home/b/e/bestweb/public_html/captcha/3/samplePost.php on line 25
        [alt]Human Input Validation Failed

--
regards,

------------------------------------------------------------
Nelson Rodríguez-Peña A.
Diseño y Desarrollo Web y Multimedia
------------------------------------------------------------

attached mail follows:


[snip]
> http://zirzow.dyndns.org/html/mlists/php_general/

The fact that you're the top responder in the last 30 days pretty much
confirms you have too much spare time Curt!
[/snip]

LOL! Very revealing and funny stuff ....

attached mail follows:


[snip]
And whats really scary is I'm tempted to do that :) I can easily
read all the 164194 messages sitting on the news server (since May
2000) and then build a summary poster summary page.

Then I just need to come up with some logic to determain who has a
tendency to (be) flamed.
[/snip]

You may also want to include logic to determine who is most likely to do
the flaming.

:)

attached mail follows:


And possibly the best looking site I've seen in years. Colours, curves -
bring it on....

PLENTY of spare time I think...

C

-----Original Message-----
From: Jay Blanchard [mailto:jay.blanchardniicommunications.com]
Sent: 29 September 2003 13:00
To: Justin French; Curt Zirzow
Cc: php-generallists.php.net
Subject: RE: [PHP] PHP coders spare time [OT}

[snip]
> http://zirzow.dyndns.org/html/mlists/php_general/

The fact that you're the top responder in the last 30 days pretty much
confirms you have too much spare time Curt!
[/snip]

LOL! Very revealing and funny stuff ....

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
 
If you are not the intended recipient of this e-mail, please preserve the
confidentiality of it and advise the sender immediately of any error in
transmission. Any disclosure, copying, distribution or action taken, or
omitted to be taken, by an unauthorised recipient in reliance upon the
contents of this e-mail is prohibited. Somerfield cannot accept liability
for any damage which you may sustain as a result of software viruses so
please carry out your own virus checks before opening an attachment. In
replying to this e-mail you are granting the right for that reply to be
forwarded to any other individual within the business and also to be read by
others. Any views expressed by an individual within this message do not
necessarily reflect the views of Somerfield. Somerfield reserves the right
to intercept, monitor and record communications for lawful business
purposes.

attached mail follows:


From: "Marek Kilimajer" <kilimajerwebglobe.sk>

> "CPT John W. Holmes" <holmes072000charter.net> and "John W. Holmes"
> <holmes072000charter.net> is the same address, just a different name
> (in and out of office ;) John made it to be second.

Maybe this list shouldn't be public, since it appears I send just as much
email from work as I do at home.... ;)

---John Holmes...

attached mail follows:


Curt Zirzow <mailto:php-generalzirzow.dyndns.org>
    on Sunday, September 28, 2003 6:50 PM said:

> And what they do with it...
>
> http://zirzow.dyndns.org/html/mlists/php_general/

Two comments:

1. Top 10! w00t! w00t!
2. Good job Curt.

Chris.

attached mail follows:


Very nice!

--
Jon Kriek
http://phpfreaks.com

"Chris W. Parker" <cparkerswatgear.com> wrote in message
news:001BD19C96E6E64E8750D72C2EA0ECEE2B80DAati-ex-01.ati.local...
Curt Zirzow <mailto:php-generalzirzow.dyndns.org>
    on Sunday, September 28, 2003 6:50 PM said:

> And what they do with it...
>
> http://zirzow.dyndns.org/html/mlists/php_general/

attached mail follows:


hello,

i am looking for a function that easily searches a sting backwards -
just like stripos but reversed. is there already one part of php or does
anyone have a nice function written? right now i do it by reversing the
sting and using strpos, but this is highly inefficient. any ideas/solutions?

thanks,
Chris

attached mail follows:


* Thus wrote Chris Widmer (pogogibts.net):
> hello,
>
> i am looking for a function that easily searches a sting backwards -
> just like stripos but reversed. is there already one part of php or does
> anyone have a nice function written? right now i do it by reversing the
> sting and using strpos, but this is highly inefficient. any ideas/solutions?

You could use the strrchr function to achieve this:

$pos = strrpos(strtolower($str), $needle);

Curt
--
"I used to think I was indecisive, but now I'm not so sure."

attached mail follows:


I know exporting xls file to csv (or other tagged export) is not very
difficult but in order to make a « all-users » application we must
accept xls files.

 

Cordialement,
Jean-Philippe BENARD
Consultant STERIA Infogérance
(jean-philippe.benard-renexterrenault.com)

-----Message d'origine-----
De : Kevin Bruce [mailto:brucemdsg.umd.edu]
Envoyé : lundi 29 septembre 2003 14:40
À : BENARD Jean-philippe
Objet : Re: [PHP] PHP & Rading excel files

 

I created a database dump that accepts tab delimited files. You'd have
to export your xls file to a tab delimited file (which is a no-brainer).

Here is the code (it was made to import into a user database, change it
to suite your purposes):

                <?

if(!$dump)
{
                    ?>
                  There are currently <b><?php echo $total ?></b>
entries in the
                  <?php echo $user_admin ?> database.<br>
                  Choose your <?php echo $mod_name ?> Admin action from
the above
                  menu. </font></p>
                <h1><font size="2">Database Import</font></h1>
                <font size="2">
                <form action="<?php echo $_SERVER[PHP_SELF]
?>?dump=predump&category=<?php echo $category ?>" method="post"
enctype="multipart/form-data" name="form1">
                  <font size="2"> Tab Delimited File Database Import
                  <input type="file" name="file" accesskey="1"></label>
                  <input name="user_level" type="hidden" id="user_level"
value="<?php echo $category ?>">
                  <br>
                  <input type="submit" name="Submit" value="Submit">
                  </font>
                </form>
                <?php
}

if($dump == "predump")
{
        if(!$file_name)
        {
            echo "File did not upload! Please hit your back button and
upload your import file.";
        }
        else
        {
            //read file
            $fp = fopen($file, "r");
            $data = fread($fp, filesize($file));
            fclose($fp);
            $fileC = explode("\r", $data);
            flush();

            //get the 1st line, which usually contains the field names
            $sample = $fileC[0];

            //get the longest entry as a sample of all fields, just in
case the first line doesn't contain the field names
            $sample2 = max($fileC);
            $samplenum = explode("\t",$sample);
            $numfields = count($samplenum);
            $sample = "<td>" .
str_replace("\t","&nbsp;</td><td>",$sample) . "&nbsp;</td>\n";
            $sample2 = "<td>" .
str_replace("\t","&nbsp;</td><td>",$sample2) . "&nbsp;</td>\n";

            //set the form variable to carry over into next form
            $import = implode($fileC,"|");
?>
                <form name="form2" method="post" action="<?php echo
$_SERVER[PHP_SELF] ?>?dump=dump&category=<?php echo $category ?>">
                  <input name="category" type="hidden" value="<?php echo
$category ?>">
                  <?php
                $fieldrop = fieldrop($dbh,$DBname,$tablename);
                ?>
                  <table border="1" cellpadding="5" cellspacing="0"
bordercolor="#6666CC" summary="Match up the database fields with the
sample entry form this import">
                    <caption align="top">
                    Match up the database fields with the sample entry
form this
                    import <br>
                    There are <?php echo $numfields - 1; ?>-<?php echo
$numfields; ?> entries in this import.
                    </caption>
                    <tr bgcolor="#6666CC">
                      <?php
                for($n=0;$n<$numfields;$n++)
                {
                      echo "<td>
                        <div align=\"center\">
                          <select name=\"field[$n]\" id=\"field[$n]\">

                            echo $fieldrop
                          </select>
                        </div></td>";
                }
                ?>
                    </tr>
                    <tr class="fonty"> <?php echo $sample ?> </tr>
                    <tr class="fonty"> <?php echo $sample2 ?> </tr>
                    <tr bgcolor="#6666CC">
                      <td colspan="15"> <div align="center"><font
size="2">
                          <input name="numfields" type="hidden"
value="<?php echo $numfields; ?>">
                          <input name="import" type="hidden"
value="<?php echo base64_encode($import) ?>">
                          </font></div>
                        <div align="center"><font size="2"><font
size="2"> <br>
                                <label>
                            <input name="notify" type="checkbox"
value="1" checked>
                            Send welcome email to imported entries.
(choosing this means it will take appximately <?php echo $numfields - 1;
?>-<?php echo $numfields; ?> seconds to complete the import)</label>
                          <br>
                          <input type="submit" name="Submit"
value="Submit">
                          </font></font></div></td>
                    </tr>
                  </table>
                </form>
                <?php
            }
}
elseif($dump == "dump")
{
    //set up the insert query
    $insert = "";
    $maxfield = count($field);
    for($n=0; $n<$numfields;$n++)
    {
        $line = each($field);
        if($line[value]>'')
        {
            $insert .= $line[value] . ",";
        }
    }

    //remove last comma
    $insertlength = strlen($insert);
    $insert = substr($insert,0,$insertlength-1);

    //here's the insert part of the query
    $query = "INSERT INTO $tablename(nowelcomemail,user_level,$insert)
";
    
    //set up the values part

    //create main array
    $import = explode("|",base64_decode($import));

    //set the beginning of the query
    $import2 = "VALUES ";

    //how many entries in the main array
    $maxfield = count($import)-1;
    next($import);//skip the first line (the fields list)

    //for each entry in main array, create an insert
    for($n=0; $n<$maxfield;$n++)
    {
        $line = each($import);
        //check to see if there is info in this entry
        if($line[value] > '')
        {
            //turn entry into array
            $entryarray = explode("\t",$line[value]);
            $entrynum = count($entryarray); //how many fields in this
entry?
            if($entrynum == $numfields) //if the field count matches our
field count, insert into DB
            {
                $import2 .= "('1','$category','";
                //make sure the entry array has the same number of
fields that we designated in the previous form
                $import2 .=
str_replace("\t","','",addslashes($line[value]));
                $import2 .= "'), \n";// THERE! We have created the
'VALUES' part of the insert query
            }
        }
    }
    echo "Imported all entries<br>";
    $import2length = strlen($import2);
    $import2 = substr($import2,0,$import2length-3);//get rid of last
comma
    
    //Here is the actual importing
    $query2 = $query . $import2;
    mysql_query($query2,$dbh) OR die(mysql_error());
    
    $query4 = "OPTIMIZE TABLE $tablename ";
    mysql_query($query4,$dbh) OR die(mysql_error());
    
}

//function to list fields in database
function fieldrop($dbh,$DBname,$tablename)
{
    $dbresult2 = mysql_list_fields($DBname,$tablename,$dbh);
    $fields = "<option value=\"\" SELECTED>None</option>\n";
    for($i=2;$i<mysql_num_fields($dbresult2);$i++)
    {
        $fieldname = mysql_field_name($dbresult2,$i);
        $fields .= "<option value=\"$fieldname\">$fieldname</option>\n";
    }
    return $fields;
}
    ?>

> Hi !
>
> It's possible to export data to excel (csv, xml, PEAR excel file
> writing, ...) but is it possible to import data from excel ? (i.e.: I
> want to get the data which is in Cell "A1" of sheet "Toto" in the
posted
> .xls file).
>
> Thanks in advance.
>
> (o_ BENARD Jean-Philippe - Consultant STERIA Infogérance
> (o_ (o_ //\ RENAULT DTSI/ODPS/RD * ALO * API : MLB 02C 1 14
> (/)_ (\)_ V_/_ 2 Av du vieil étang * 78181 MONTIGNY-LE-BRETONNEUX
> Tél : +33 1-30-03-47-83 * Fax : +33 1-30-03-42-10

--
Kevin Bruce
Educational Web Designer
VIP K-16 Grant
http://www.scienceinquiry.org
brucemdsg.umd.edu
Maryland Sea Grant College
4321 Hartwick Road, Suite 300
College Park, MD 20740
301.403.4220 ext. 25
OR (on Wednesdays and Fridays)
717.637.5370

AOL Instant Messenger screen name- mdsgkevin

attached mail follows:


Given that excel (and generaly any microsoft app/bloatware) puts so much
junk into the files that sometimes excel itself cannot read it it is
virtualy impossible to write a pure php solution. The easiest path is to
use COM and run excel on the server, but this rules out any non windows
server. Or try to dig into openoffice and wrap its excel routines in a
php extension.

BENARD Jean-philippe wrote:

> I know exporting xls file to csv (or other tagged export) is not very
> difficult but in order to make a « all-users » application we must
> accept xls files.
>
>
>
> Cordialement,
> Jean-Philippe BENARD
> Consultant STERIA Infogérance
> (jean-philippe.benard-renexterrenault.com)
>
> -----Message d'origine-----
> De : Kevin Bruce [mailto:brucemdsg.umd.edu]
> Envoyé : lundi 29 septembre 2003 14:40
> À : BENARD Jean-philippe
> Objet : Re: [PHP] PHP & Rading excel files
>
>
>
> I created a database dump that accepts tab delimited files. You'd have
> to export your xls file to a tab delimited file (which is a no-brainer).
>
> Here is the code (it was made to import into a user database, change it
> to suite your purposes):
>
> <?
>
> if(!$dump)
> {
> ?>
> There are currently <b><?php echo $total ?></b>
> entries in the
> <?php echo $user_admin ?> database.<br>
> Choose your <?php echo $mod_name ?> Admin action from
> the above
> menu. </font></p>
> <h1><font size="2">Database Import</font></h1>
> <font size="2">
> <form action="<?php echo $_SERVER[PHP_SELF]
> ?>?dump=predump&category=<?php echo $category ?>" method="post"
> enctype="multipart/form-data" name="form1">
> <font size="2"> Tab Delimited File Database Import
> <input type="file" name="file" accesskey="1"></label>
> <input name="user_level" type="hidden" id="user_level"
> value="<?php echo $category ?>">
> <br>
> <input type="submit" name="Submit" value="Submit">
> </font>
> </form>
> <?php
> }
>
> if($dump == "predump")
> {
> if(!$file_name)
> {
> echo "File did not upload! Please hit your back button and
> upload your import file.";
> }
> else
> {
> //read file
> $fp = fopen($file, "r");
> $data = fread($fp, filesize($file));
> fclose($fp);
> $fileC = explode("\r", $data);
> flush();
>
> //get the 1st line, which usually contains the field names
> $sample = $fileC[0];
>
> //get the longest entry as a sample of all fields, just in
> case the first line doesn't contain the field names
> $sample2 = max($fileC);
> $samplenum = explode("\t",$sample);
> $numfields = count($samplenum);
> $sample = "<td>" .
> str_replace("\t","&nbsp;</td><td>",$sample) . "&nbsp;</td>\n";
> $sample2 = "<td>" .
> str_replace("\t","&nbsp;</td><td>",$sample2) . "&nbsp;</td>\n";
>
> //set the form variable to carry over into next form
> $import = implode($fileC,"|");
> ?>
> <form name="form2" method="post" action="<?php echo
> $_SERVER[PHP_SELF] ?>?dump=dump&category=<?php echo $category ?>">
> <input name="category" type="hidden" value="<?php echo
> $category ?>">
> <?php
> $fieldrop = fieldrop($dbh,$DBname,$tablename);
> ?>
> <table border="1" cellpadding="5" cellspacing="0"
> bordercolor="#6666CC" summary="Match up the database fields with the
> sample entry form this import">
> <caption align="top">
> Match up the database fields with the sample entry
> form this
> import <br>
> There are <?php echo $numfields - 1; ?>-<?php echo
> $numfields; ?> entries in this import.
> </caption>
> <tr bgcolor="#6666CC">
> <?php
> for($n=0;$n<$numfields;$n++)
> {
> echo "<td>
> <div align=\"center\">
> <select name=\"field[$n]\" id=\"field[$n]\">
>
> echo $fieldrop
> </select>
> </div></td>";
> }
> ?>
> </tr>
> <tr class="fonty"> <?php echo $sample ?> </tr>
> <tr class="fonty"> <?php echo $sample2 ?> </tr>
> <tr bgcolor="#6666CC">
> <td colspan="15"> <div align="center"><font
> size="2">
> <input name="numfields" type="hidden"
> value="<?php echo $numfields; ?>">
> <input name="import" type="hidden"
> value="<?php echo base64_encode($import) ?>">
> </font></div>
> <div align="center"><font size="2"><font
> size="2"> <br>
> <label>
> <input name="notify" type="checkbox"
> value="1" checked>
> Send welcome email to imported entries.
> (choosing this means it will take appximately <?php echo $numfields - 1;
> ?>-<?php echo $numfields; ?> seconds to complete the import)</label>
> <br>
> <input type="submit" name="Submit"
> value="Submit">
> </font></font></div></td>
> </tr>
> </table>
> </form>
> <?php
> }
> }
> elseif($dump == "dump")
> {
> //set up the insert query
> $insert = "";
> $maxfield = count($field);
> for($n=0; $n<$numfields;$n++)
> {
> $line = each($field);
> if($line[value]>'')
> {
> $insert .= $line[value] . ",";
> }
> }
>
> //remove last comma
> $insertlength = strlen($insert);
> $insert = substr($insert,0,$insertlength-1);
>
> //here's the insert part of the query
> $query = "INSERT INTO $tablename(nowelcomemail,user_level,$insert)
> ";
>
> //set up the values part
>
> //create main array
> $import = explode("|",base64_decode($import));
>
> //set the beginning of the query
> $import2 = "VALUES ";
>
> //how many entries in the main array
> $maxfield = count($import)-1;
> next($import);//skip the first line (the fields list)
>
> //for each entry in main array, create an insert
> for($n=0; $n<$maxfield;$n++)
> {
> $line = each($import);
> //check to see if there is info in this entry
> if($line[value] > '')
> {
> //turn entry into array
> $entryarray = explode("\t",$line[value]);
> $entrynum = count($entryarray); //how many fields in this
> entry?
> if($entrynum == $numfields) //if the field count matches our
> field count, insert into DB
> {
> $import2 .= "('1','$category','";
> //make sure the entry array has the same number of
> fields that we designated in the previous form
> $import2 .=
> str_replace("\t","','",addslashes($line[value]));
> $import2 .= "'), \n";// THERE! We have created the
> 'VALUES' part of the insert query
> }
> }
> }
> echo "Imported all entries<br>";
> $import2length = strlen($import2);
> $import2 = substr($import2,0,$import2length-3);//get rid of last
> comma
>
> //Here is the actual importing
> $query2 = $query . $import2;
> mysql_query($query2,$dbh) OR die(mysql_error());
>
> $query4 = "OPTIMIZE TABLE $tablename ";
> mysql_query($query4,$dbh) OR die(mysql_error());
>
> }
>
> //function to list fields in database
> function fieldrop($dbh,$DBname,$tablename)
> {
> $dbresult2 = mysql_list_fields($DBname,$tablename,$dbh);
> $fields = "<option value=\"\" SELECTED>None</option>\n";
> for($i=2;$i<mysql_num_fields($dbresult2);$i++)
> {
> $fieldname = mysql_field_name($dbresult2,$i);
> $fields .= "<option value=\"$fieldname\">$fieldname</option>\n";
> }
> return $fields;
> }
> ?>
>
>>Hi !
>>
>>It's possible to export data to excel (csv, xml, PEAR excel file
>>writing, ...) but is it possible to import data from excel ? (i.e.: I
>>want to get the data which is in Cell "A1" of sheet "Toto" in the
>
> posted
>
>>.xls file).
>>
>>Thanks in advance.
>>
>> (o_ BENARD Jean-Philippe - Consultant STERIA Infogérance
>>(o_ (o_ //\ RENAULT DTSI/ODPS/RD * ALO * API : MLB 02C 1 14
>>(/)_ (\)_ V_/_ 2 Av du vieil étang * 78181 MONTIGNY-LE-BRETONNEUX
>> Tél : +33 1-30-03-47-83 * Fax : +33 1-30-03-42-10
>
>

attached mail follows:


I'd consider using COM to work with Excel files if you can't find another
way to get the information out. The PHP Handbook (O'Reilly) has a good
chapter on that sort of thing. Then you can just refer to a cell as you
would in Excel VBA.

Sorry I can't think of anything better!

C

-----Original Message-----
From: BENARD Jean-philippe
[mailto:jean-philippe.benard-renexterrenault.com]
Sent: 29 September 2003 13:24
To: 'Kevin Bruce'
Cc: php-generallists.php.net
Subject: [PHP] RE : [PHP] PHP & Rading excel files

I know exporting xls file to csv (or other tagged export) is not very
difficult but in order to make a « all-users » application we must
accept xls files.

 

Cordialement,
Jean-Philippe BENARD
Consultant STERIA Infogérance
(jean-philippe.benard-renexterrenault.com)

-----Message d'origine-----
De : Kevin Bruce [mailto:brucemdsg.umd.edu]
Envoyé : lundi 29 septembre 2003 14:40
À : BENARD Jean-philippe
Objet : Re: [PHP] PHP & Rading excel files

 

I created a database dump that accepts tab delimited files. You'd have
to export your xls file to a tab delimited file (which is a no-brainer).

Here is the code (it was made to import into a user database, change it
to suite your purposes):

                <?

if(!$dump)
{
                    ?>
                  There are currently <b><?php echo $total ?></b>
entries in the
                  <?php echo $user_admin ?> database.<br>
                  Choose your <?php echo $mod_name ?> Admin action from
the above
                  menu. </font></p>
                <h1><font size="2">Database Import</font></h1>
                <font size="2">
                <form action="<?php echo $_SERVER[PHP_SELF]
?>?dump=predump&category=<?php echo $category ?>" method="post"
enctype="multipart/form-data" name="form1">
                  <font size="2"> Tab Delimited File Database Import
                  <input type="file" name="file" accesskey="1"></label>
                  <input name="user_level" type="hidden" id="user_level"
value="<?php echo $category ?>">
                  <br>
                  <input type="submit" name="Submit" value="Submit">
                  </font>
                </form>
                <?php
}

if($dump == "predump")
{
        if(!$file_name)
        {
            echo "File did not upload! Please hit your back button and
upload your import file.";
        }
        else
        {
            //read file
            $fp = fopen($file, "r");
            $data = fread($fp, filesize($file));
            fclose($fp);
            $fileC = explode("\r", $data);
            flush();

            //get the 1st line, which usually contains the field names
            $sample = $fileC[0];

            //get the longest entry as a sample of all fields, just in
case the first line doesn't contain the field names
            $sample2 = max($fileC);
            $samplenum = explode("\t",$sample);
            $numfields = count($samplenum);
            $sample = "<td>" .
str_replace("\t","&nbsp;</td><td>",$sample) . "&nbsp;</td>\n";
            $sample2 = "<td>" .
str_replace("\t","&nbsp;</td><td>",$sample2) . "&nbsp;</td>\n";

            //set the form variable to carry over into next form
            $import = implode($fileC,"|");
?>
                <form name="form2" method="post" action="<?php echo
$_SERVER[PHP_SELF] ?>?dump=dump&category=<?php echo $category ?>">
                  <input name="category" type="hidden" value="<?php echo
$category ?>">
                  <?php
                $fieldrop = fieldrop($dbh,$DBname,$tablename);
                ?>
                  <table border="1" cellpadding="5" cellspacing="0"
bordercolor="#6666CC" summary="Match up the database fields with the
sample entry form this import">
                    <caption align="top">
                    Match up the database fields with the sample entry
form this
                    import <br>
                    There are <?php echo $numfields - 1; ?>-<?php echo
$numfields; ?> entries in this import.
                    </caption>
                    <tr bgcolor="#6666CC">
                      <?php
                for($n=0;$n<$numfields;$n++)
                {
                      echo "<td>
                        <div align=\"center\">
                          <select name=\"field[$n]\" id=\"field[$n]\">

                            echo $fieldrop
                          </select>
                        </div></td>";
                }
                ?>
                    </tr>
                    <tr class="fonty"> <?php echo $sample ?> </tr>
                    <tr class="fonty"> <?php echo $sample2 ?> </tr>
                    <tr bgcolor="#6666CC">
                      <td colspan="15"> <div align="center"><font
size="2">
                          <input name="numfields" type="hidden"
value="<?php echo $numfields; ?>">
                          <input name="import" type="hidden"
value="<?php echo base64_encode($import) ?>">
                          </font></div>
                        <div align="center"><font size="2"><font
size="2"> <br>
                                <label>
                            <input name="notify" type="checkbox"
value="1" checked>
                            Send welcome email to imported entries.
(choosing this means it will take appximately <?php echo $numfields - 1;
?>-<?php echo $numfields; ?> seconds to complete the import)</label>
                          <br>
                          <input type="submit" name="Submit"
value="Submit">
                          </font></font></div></td>
                    </tr>
                  </table>
                </form>
                <?php
            }
}
elseif($dump == "dump")
{
    //set up the insert query
    $insert = "";
    $maxfield = count($field);
    for($n=0; $n<$numfields;$n++)
    {
        $line = each($field);
        if($line[value]>'')
        {
            $insert .= $line[value] . ",";
        }
    }

    //remove last comma
    $insertlength = strlen($insert);
    $insert = substr($insert,0,$insertlength-1);

    //here's the insert part of the query
    $query = "INSERT INTO $tablename(nowelcomemail,user_level,$insert)
";
    
    //set up the values part

    //create main array
    $import = explode("|",base64_decode($import));

    //set the beginning of the query
    $import2 = "VALUES ";

    //how many entries in the main array
    $maxfield = count($import)-1;
    next($import);//skip the first line (the fields list)

    //for each entry in main array, create an insert
    for($n=0; $n<$maxfield;$n++)
    {
        $line = each($import);
        //check to see if there is info in this entry
        if($line[value] > '')
        {
            //turn entry into array
            $entryarray = explode("\t",$line[value]);
            $entrynum = count($entryarray); //how many fields in this
entry?
            if($entrynum == $numfields) //if the field count matches our
field count, insert into DB
            {
                $import2 .= "('1','$category','";
                //make sure the entry array has the same number of
fields that we designated in the previous form
                $import2 .=
str_replace("\t","','",addslashes($line[value]));
                $import2 .= "'), \n";// THERE! We have created the
'VALUES' part of the insert query
            }
        }
    }
    echo "Imported all entries<br>";
    $import2length = strlen($import2);
    $import2 = substr($import2,0,$import2length-3);//get rid of last
comma
    
    //Here is the actual importing
    $query2 = $query . $import2;
    mysql_query($query2,$dbh) OR die(mysql_error());
    
    $query4 = "OPTIMIZE TABLE $tablename ";
    mysql_query($query4,$dbh) OR die(mysql_error());
    
}

//function to list fields in database
function fieldrop($dbh,$DBname,$tablename)
{
    $dbresult2 = mysql_list_fields($DBname,$tablename,$dbh);
    $fields = "<option value=\"\" SELECTED>None</option>\n";
    for($i=2;$i<mysql_num_fields($dbresult2);$i++)
    {
        $fieldname = mysql_field_name($dbresult2,$i);
        $fields .= "<option value=\"$fieldname\">$fieldname</option>\n";
    }
    return $fields;
}
    ?>

> Hi !
>
> It's possible to export data to excel (csv, xml, PEAR excel file
> writing, ...) but is it possible to import data from excel ? (i.e.: I
> want to get the data which is in Cell "A1" of sheet "Toto" in the
posted
> .xls file).
>
> Thanks in advance.
>
> (o_ BENARD Jean-Philippe - Consultant STERIA Infogérance
> (o_ (o_ //\ RENAULT DTSI/ODPS/RD * ALO * API : MLB 02C 1 14
> (/)_ (\)_ V_/_ 2 Av du vieil étang * 78181 MONTIGNY-LE-BRETONNEUX
> Tél : +33 1-30-03-47-83 * Fax : +33 1-30-03-42-10

--
Kevin Bruce
Educational Web Designer
VIP K-16 Grant
http://www.scienceinquiry.org
brucemdsg.umd.edu
Maryland Sea Grant College
4321 Hartwick Road, Suite 300
College Park, MD 20740
301.403.4220 ext. 25
OR (on Wednesdays and Fridays)
717.637.5370

AOL Instant Messenger screen name- mdsgkevin

 
If you are not the intended recipient of this e-mail, please preserve the
confidentiality of it and advise the sender immediately of any error in
transmission. Any disclosure, copying, distribution or action taken, or
omitted to be taken, by an unauthorised recipient in reliance upon the
contents of this e-mail is prohibited. Somerfield cannot accept liability
for any damage which you may sustain as a result of software viruses so
please carry out your own virus checks before opening an attachment. In
replying to this e-mail you are granting the right for that reply to be
forwarded to any other individual within the business and also to be read by
others. Any views expressed by an individual within this message do not
necessarily reflect the views of Somerfield. Somerfield reserves the right
to intercept, monitor and record communications for lawful business
purposes.

attached mail follows:


Just thought that it might be worth considering putting some functionality
into the Excel spreadsheet to trigger the PHP application.

I've created Excel spreadsheets in the past with a VBA macro or two in it
which allows users to update information on a intranet site from the
spreadsheet. They update their spreadsheet as normal and then press a button
which opens up a web browser control and passes the information to the
server in a get statement. Page reloads, capture the return message from the
server and show to user who never sees the web browser.

I don't know exactly what you're developing so can't be sure if this will be
of any use.

Regards

Chris

-----Original Message-----
From: Marek Kilimajer [mailto:kilimajerwebglobe.sk]
Sent: 29 September 2003 13:41
To: BENARD Jean-philippe
Cc: php-generallists.php.net
Subject: Re: [PHP] RE : [PHP] PHP & Rading excel files

Given that excel (and generaly any microsoft app/bloatware) puts so much
junk into the files that sometimes excel itself cannot read it it is
virtualy impossible to write a pure php solution. The easiest path is to
use COM and run excel on the server, but this rules out any non windows
server. Or try to dig into openoffice and wrap its excel routines in a
php extension.

BENARD Jean-philippe wrote:

> I know exporting xls file to csv (or other tagged export) is not very
> difficult but in order to make a « all-users » application we must
> accept xls files.
>
>
>
> Cordialement,
> Jean-Philippe BENARD
> Consultant STERIA Infogérance
> (jean-philippe.benard-renexterrenault.com)
>
> -----Message d'origine-----
> De : Kevin Bruce [mailto:brucemdsg.umd.edu]
> Envoyé : lundi 29 septembre 2003 14:40
> À : BENARD Jean-philippe
> Objet : Re: [PHP] PHP & Rading excel files
>
>
>
> I created a database dump that accepts tab delimited files. You'd have
> to export your xls file to a tab delimited file (which is a no-brainer).
>
> Here is the code (it was made to import into a user database, change it
> to suite your purposes):
>
> <?
>
> if(!$dump)
> {
> ?>
> There are currently <b><?php echo $total ?></b>
> entries in the
> <?php echo $user_admin ?> database.<br>
> Choose your <?php echo $mod_name ?> Admin action from
> the above
> menu. </font></p>
> <h1><font size="2">Database Import</font></h1>
> <font size="2">
> <form action="<?php echo $_SERVER[PHP_SELF]
> ?>?dump=predump&category=<?php echo $category ?>" method="post"
> enctype="multipart/form-data" name="form1">
> <font size="2"> Tab Delimited File Database Import
> <input type="file" name="file" accesskey="1"></label>
> <input name="user_level" type="hidden" id="user_level"
> value="<?php echo $category ?>">
> <br>
> <input type="submit" name="Submit" value="Submit">
> </font>
> </form>
> <?php
> }
>
> if($dump == "predump")
> {
> if(!$file_name)
> {
> echo "File did not upload! Please hit your back button and
> upload your import file.";
> }
> else
> {
> //read file
> $fp = fopen($file, "r");
> $data = fread($fp, filesize($file));
> fclose($fp);
> $fileC = explode("\r", $data);
> flush();
>
> //get the 1st line, which usually contains the field names
> $sample = $fileC[0];
>
> //get the longest entry as a sample of all fields, just in
> case the first line doesn't contain the field names
> $sample2 = max($fileC);
> $samplenum = explode("\t",$sample);
> $numfields = count($samplenum);
> $sample = "<td>" .
> str_replace("\t","&nbsp;</td><td>",$sample) . "&nbsp;</td>\n";
> $sample2 = "<td>" .
> str_replace("\t","&nbsp;</td><td>",$sample2) . "&nbsp;</td>\n";
>
> //set the form variable to carry over into next form
> $import = implode($fileC,"|");
> ?>
> <form name="form2" method="post" action="<?php echo
> $_SERVER[PHP_SELF] ?>?dump=dump&category=<?php echo $category ?>">
> <input name="category" type="hidden" value="<?php echo
> $category ?>">
> <?php
> $fieldrop = fieldrop($dbh,$DBname,$tablename);
> ?>
> <table border="1" cellpadding="5" cellspacing="0"
> bordercolor="#6666CC" summary="Match up the database fields with the
> sample entry form this import">
> <caption align="top">
> Match up the database fields with the sample entry
> form this
> import <br>
> There are <?php echo $numfields - 1; ?>-<?php echo
> $numfields; ?> entries in this import.
> </caption>
> <tr bgcolor="#6666CC">
> <?php
> for($n=0;$n<$numfields;$n++)
> {
> echo "<td>
> <div align=\"center\">
> <select name=\"field[$n]\" id=\"field[$n]\">
>
> echo $fieldrop
> </select>
> </div></td>";
> }
> ?>
> </tr>
> <tr class="fonty"> <?php echo $sample ?> </tr>
> <tr class="fonty"> <?php echo $sample2 ?> </tr>
> <tr bgcolor="#6666CC">
> <td colspan="15"> <div align="center"><font
> size="2">
> <input name="numfields" type="hidden"
> value="<?php echo $numfields; ?>">
> <input name="import" type="hidden"
> value="<?php echo base64_encode($import) ?>">
> </font></div>
> <div align="center"><font size="2"><font
> size="2"> <br>
> <label>
> <input name="notify" type="checkbox"
> value="1" checked>
> Send welcome email to imported entries.
> (choosing this means it will take appximately <?php echo $numfields - 1;
> ?>-<?php echo $numfields; ?> seconds to complete the import)</label>
> <br>
> <input type="submit" name="Submit"
> value="Submit">
> </font></font></div></td>
> </tr>
> </table>
> </form>
> <?php
> }
> }
> elseif($dump == "dump")
> {
> //set up the insert query
> $insert = "";
> $maxfield = count($field);
> for($n=0; $n<$numfields;$n++)
> {
> $line = each($field);
> if($line[value]>'')
> {
> $insert .= $line[value] . ",";
> }
> }
>
> //remove last comma
> $insertlength = strlen($insert);
> $insert = substr($insert,0,$insertlength-1);
>
> //here's the insert part of the query
> $query = "INSERT INTO $tablename(nowelcomemail,user_level,$insert)
> ";
>
> //set up the values part
>
> //create main array
> $import = explode("|",base64_decode($import));
>
> //set the beginning of the query
> $import2 = "VALUES ";
>
> //how many entries in the main array
> $maxfield = count($import)-1;
> next($import);//skip the first line (the fields list)
>
> //for each entry in main array, create an insert
> for($n=0; $n<$maxfield;$n++)
> {
> $line = each($import);
> //check to see if there is info in this entry
> if($line[value] > '')
> {
> //turn entry into array
> $entryarray = explode("\t",$line[value]);
> $entrynum = count($entryarray); //how many fields in this
> entry?
> if($entrynum == $numfields) //if the field count matches our
> field count, insert into DB
> {
> $import2 .= "('1','$category','";
> //make sure the entry array has the same number of
> fields that we designated in the previous form
> $import2 .=
> str_replace("\t","','",addslashes($line[value]));
> $import2 .= "'), \n";// THERE! We have created the
> 'VALUES' part of the insert query
> }
> }
> }
> echo "Imported all entries<br>";
> $import2length = strlen($import2);
> $import2 = substr($import2,0,$import2length-3);//get rid of last
> comma
>
> //Here is the actual importing
> $query2 = $query . $import2;
> mysql_query($query2,$dbh) OR die(mysql_error());
>
> $query4 = "OPTIMIZE TABLE $tablename ";
> mysql_query($query4,$dbh) OR die(mysql_error());
>
> }
>
> //function to list fields in database
> function fieldrop($dbh,$DBname,$tablename)
> {
> $dbresult2 = mysql_list_fields($DBname,$tablename,$dbh);
> $fields = "<option value=\"\" SELECTED>None</option>\n";