FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


from excel to php ?





peanutz
hi

i have a excel file that i need to use in php, and i have no idea how to do that...

please help ?

thanx
cafefort
Hi Smile

Maybe you'll need some kind of excel to mysql converter.
Take a look to this one:
http://www.idigweb.com/excel2mysql/

If it doesn't satisfy your needs, just go to
http://hotscripts.com/PHP

or http://php.resourceindex.com

or simply ask our friend google:
google search for excel to mysql php

Hope this helps Smile
peanutz
thanx for your answer !

i like the first link, ufnortunately there's an error during the process, my xls file is not readable apparently... why do you think that is ? Here's the error message :

'Warning: fopen(Mysql_idigweb.txt): failed to open stream: File exists in /home/idigweb/public_html/excel2mysql/excel2mysql.php on line 44

Warning: fwrite(): supplied argument is not a valid stream resource in /home/idigweb/public_html/excel2mysql/excel2mysql.php on line 68
Cannot write to file (Mysql_idigweb.txt)

Warning: move_uploaded_file(/home/ereidy/public_html/script/excel2mysql/upload_excel/Totalphp.xls): failed to open stream: No such file or directory in /home/idigweb/public_html/excel2mysql/excel2mysql.php on line 91

Warning: move_uploaded_file(): Unable to move '/tmp/phpM66TSm' to '/home/ereidy/public_html/script/excel2mysql/upload_excel/Totalphp.xls' in /home/idigweb/public_html/excel2mysql/excel2mysql.php on line 91

Upload failed! Please try it again!

The filename /home/ereidy/public_html/script/excel2mysql/upload_excel/Totalphp.xls is not readable'
Nyizsa
Try importing it to Access - I think it is possible to export it to a MySQL database. I am not sure, though.
Or you can experiment with PHP's ODBC connection. However, I don't recommend this.
AftershockVibe
Your upload script looks like it isn't working because it does not have write access to the directory you're trying to put the file into. Chmod the rights via FTP.

An alternative solution would be to save your file as a .csv file (save as...) and write a short PHP script to parse the comma delimited values.
peanutz
AftershockVibe wrote:
An alternative solution would be to save your file as a .csv file (save as...) and write a short PHP script to parse the comma delimited values.


YES ! excellent idea !
i thought of the csv file... and yes i can write a short script for the commas... except that i'm a very beginner and i don't know if the explode function would work

why a txt file doesn't work btw ?
peanutz
<?php
echo "<form method='post' action='esssai cvs.php'>";

$fp = @fopen ("totalphp.csv","r")
or die ("<center><font color=\"#FF0000\" size=5>impossible to open file</font><center>");

$lignes=0;
while ($data = @fgetcsv ($fp, 1000, ";")) {

$num = count ($data);

for ($c=0; $c<$num; $c++) {

$data[$c]=str_replace('"','&quot;',$data[$c]);
$data[$c]=str_replace("'","\'",$data[$c]);
$tabannonces[$lignes][$c]=$data[$c];

}
$lignes++;
}
fclose ($fp);
$case=0; $numero=0;

/* TABLE HTML */

echo "<center><font color=\"#0000FF\" size=5><b><u>Title</U></b></font></center><br>";
echo "<center><table bgcolor='#000000' cellspacing='1'>";

for ($ligne=1 ; $ligne<=$lignes ; $ligne++) {
echo "<tr>";
for ($colonne=1 ; $colonne<=$num ; $colonne++) {
echo "<td bgcolor='#FFFFFF'align=center>&nbsp;".$tabannonces[$ligne-1][$colonne-1]."&nbsp;</td>";
}
$case++;
if ($case == 1 ){
echo "<td bgcolor='#FFFFFF'align=center>&nbsp;Selection&nbsp</td>";}
if ($case > 1 ){
echo "<td bgcolor='#FFFFFF'align=center><input type=\"checkbox\" name=\".$numero.\" value=\"musique\"></td>";}
$numero++;
echo "</tr>";
}
$nbcolspans=$num-1;
echo "<tr><td bgcolor='#FFFFFF' colspan='".$nbcolspans."'>&nbsp;</td><td align='right' bgcolor='#FFFFFF'>
<input type='Submit' value='Enregistrer' class='monform'></td></tr>";
echo "</table></center>";
echo "</form><p>";

?>

ok i've been helped for this one... but i have an error :
"Notice: Undefined offset: 11 in d:\program files\easyphp1-8\www\essai\tableau1.php on line 42
Notice: Undefined offset: 12 in d:\program files\easyphp1-8\www\essai\tableau1.php on line 42"

which correspond to the underlined part... where's the mistake ?
Related topics
http://tuvanonline.com/library/index.php
PHP-Nuke platium?
PHP Write to line
Anyone good with PHP-NUKE?
PHP safety?
req: PHP to list files in directory, and link to them
php admin and mysql admin console
Mysql And PHP HELP PLZ
Working with Excel, PHP & MySQL. Any Ideas
A very good PHP MySQL Tutorial
converting <TABLE> to CSV
php-mysql source code
Export Image to Excel
excel database
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.