Hi All,
Use this code..
For this program to run create database SNITDB and create a table tweet(tid,sname,tweet)
----------------------------------------------------------
<?php
$con=mysql_connect("localhost","root","");
mysql_select_db("SNITDB",$con);
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=da.csv');
$output = fopen("php://output", "w");
fputcsv($output, array('tid','sname', 'tweet'));
$query = "select distinct * from tweet where label=0";
$result = mysql_query($query, $con);
while($row = mysql_fetch_array($result))
{
fputcsv($output,array($row['tid'],$row['sname'],$row['tweet']));
$sql="update tweet set label=1 where tid='$row[tid]'";
mysql_query($sql, $con);
}
fclose($output);
?>
Use this code..
For this program to run create database SNITDB and create a table tweet(tid,sname,tweet)
----------------------------------------------------------
<?php
$con=mysql_connect("localhost","root","");
mysql_select_db("SNITDB",$con);
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=da.csv');
$output = fopen("php://output", "w");
fputcsv($output, array('tid','sname', 'tweet'));
$query = "select distinct * from tweet where label=0";
$result = mysql_query($query, $con);
while($row = mysql_fetch_array($result))
{
fputcsv($output,array($row['tid'],$row['sname'],$row['tweet']));
$sql="update tweet set label=1 where tid='$row[tid]'";
mysql_query($sql, $con);
}
fclose($output);
?>
No comments:
Post a Comment