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
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'
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.
<?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('"','"',$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> ".$tabannonces[$ligne-1][$colonne-1]." </td>";
}
$case++;
if ($case == 1 ){
echo "<td bgcolor='#FFFFFF'align=center> Selection </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."'> </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 ?