Export CSV datas to mysql tables
LOAD DATA INFILE 'data.csv' INTO TABLE tbl_name
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n';
Export Excel sheet datas to mysql tables
LOAD DATA INFILE 'data.csv' INTO TABLE tbl_name
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n';
Export XML spread sheet datas to mysql tables
LOAD DATA INFILE 'data.csv' INTO TABLE tbl_name
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n';
Saturday, August 30, 2008
Load Data Infile Syntax
LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name
'
[REPLACE | IGNORE]
INTO TABLEtbl_name
[CHARACTER SETcharset_name
]
[{FIELDS | COLUMNS}
[TERMINATED BY 'string
']
[[OPTIONALLY] ENCLOSED BY 'char
']
[ESCAPED BY 'char
']
]
[LINES
[STARTING BY 'string
']
[TERMINATED BY 'string
']
]
[IGNOREnumber
LINES]
[(col_name_or_user_var
,...)]
[SETcol_name
=expr
,...]
Wednesday, August 20, 2008
PHP checkbox array checked
<form action="checkbox_array_checked.php" method="post">
<input type="checkbox" name="check[]" value="sakkarakati" <? if (in_array('sakkarakati', $_POST['check'])) { ?> checked="checked" <? }?>/> Sakkarakati<br>
<input type="checkbox" name="check[]" value="kuselan" <? if (in_array('kuselan', $_POST['check'])) { ?> checked="checked"<? }?> /> Kuselan<br>
<input type="checkbox" name="check[]" value="villu" <? if (in_array('villu', $_POST['check'])) { ?> checked="checked"<? }?> /> Villu<br>
</form>
<input type="checkbox" name="check[]" value="sakkarakati" <? if (in_array('sakkarakati', $_POST['check'])) { ?> checked="checked" <? }?>/> Sakkarakati<br>
<input type="checkbox" name="check[]" value="kuselan" <? if (in_array('kuselan', $_POST['check'])) { ?> checked="checked"<? }?> /> Kuselan<br>
<input type="checkbox" name="check[]" value="villu" <? if (in_array('villu', $_POST['check'])) { ?> checked="checked"<? }?> /> Villu<br>
</form>
Saturday, August 9, 2008
PHP file download using header functions
header("Cache-Control: public");
header("Content-Description: File Transfer");
header('Content-disposition: attachment; filename='.basename($filename));
header("Content-Type: application/pdf");
header("Content-Transfer-Encoding: binary");
header('Content-Length: '. filesize($filename));
readfile($filename);
header("Content-Description: File Transfer");
header('Content-disposition: attachment; filename='.basename($filename));
header("Content-Type: application/pdf");
header("Content-Transfer-Encoding: binary");
header('Content-Length: '. filesize($filename));
readfile($filename);
PHP header file types
header('Content-type: application/pdf');
header('Location: http://ashokseenivas.blogspot.com/');
header("HTTP/1.0 404 Not Found");
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sun, 10 Aug 2008 05:00:00 GMT");
header('Content-type: text/xml');
header('Location: http://ashokseenivas.blogspot.com/');
header("HTTP/1.0 404 Not Found");
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sun, 10 Aug 2008 05:00:00 GMT");
header('Content-type: text/xml');
Monday, August 4, 2008
PHP Filesystem - fopen, fread, fputs or fwrite, filesize
<?
if (isset($_POST['Submit']))
{
$file = '\rajini-kuselan.php';
$filecontent = $_POST['filecontent'];
if ($fp = fopen ($file, 'w'))
{
fputs( $fp, stripslashes( $filecontent ) );
fclose( $fp );
}
}
$file = '\rajini-kuselan.php';
$fp = fopen( $file, 'r' );
$content = fread( $fp, filesize( $file ) );
$content = htmlspecialchars( $content );
?>
<form name="kuselan.php" method="post">
<textarea style="width:100%;height:500px" cols="110" rows="25" name="filecontent"><? echo $content;?></textarea>
<input type="submit" name="Submit" value="Submit" />
</form>
if (isset($_POST['Submit']))
{
$file = '\rajini-kuselan.php';
$filecontent = $_POST['filecontent'];
if ($fp = fopen ($file, 'w'))
{
fputs( $fp, stripslashes( $filecontent ) );
fclose( $fp );
}
}
$file = '\rajini-kuselan.php';
$fp = fopen( $file, 'r' );
$content = fread( $fp, filesize( $file ) );
$content = htmlspecialchars( $content );
?>
<form name="kuselan.php" method="post">
<textarea style="width:100%;height:500px" cols="110" rows="25" name="filecontent"><? echo $content;?></textarea>
<input type="submit" name="Submit" value="Submit" />
</form>
Subscribe to:
Posts (Atom)