" CLEAR DATABASE" FUNCTION IN PHP
In html body tag <div style='float:right'><input type='button' value='Clear' onclick='val()'></div>
<?php
$con=mysql_connect('localhost','root','');
mysql_select_db('db_name',$con);
if(!$con)
{
die("could not found");
}
else
{
echo "CONNECTED TO DATABASE.</br>";
}
mysql_query("DELETE FROM `db_data/table-name`");
mysql_query("DELETE FROM `db_table3`");
?>
<a href='index.php'>Home</a>
http://www.w3schools.com/php/php_mysql_insert.asp
--------------------------------------------------------------------------------
while (!feof($h))
{
$str=fgets($h,4096);//read a line
list($a,$b,$c)=(explode("-",$str));//seperate a string by means of |
echo $a."-".$b."-".$c."</br>";
$ch=strlen($c);
if($ch==10)
{
//echo $c."<br>";
$s=mysql_query("INSERT into db_table3(`fname`,`lname`,`phone_number`) VALUES('$a','$b','$c')");
$r=mysql_query($s,$con);
}
else{
$ph="022".$c."<br>";
//echo $ph;
$sq=mysql_query("INSERT into db_table3(`fname`,`lname`,`phone_number`) VALUES('$a','$b','$ph')");
$re=mysql_query($sq,$con);
}
}
fclose($h);
In html body tag <div style='float:right'><input type='button' value='Clear' onclick='val()'></div>
<?php
$con=mysql_connect('localhost','root','');
mysql_select_db('db_name',$con);
if(!$con)
{
die("could not found");
}
else
{
echo "CONNECTED TO DATABASE.</br>";
}
mysql_query("DELETE FROM `db_data/table-name`");
mysql_query("DELETE FROM `db_table3`");
?>
<a href='index.php'>Home</a>
http://www.w3schools.com/php/php_mysql_insert.asp
--------------------------------------------------------------------------------
while (!feof($h))
{
$str=fgets($h,4096);//read a line
list($a,$b,$c)=(explode("-",$str));//seperate a string by means of |
echo $a."-".$b."-".$c."</br>";
$ch=strlen($c);
if($ch==10)
{
//echo $c."<br>";
$s=mysql_query("INSERT into db_table3(`fname`,`lname`,`phone_number`) VALUES('$a','$b','$c')");
$r=mysql_query($s,$con);
}
else{
$ph="022".$c."<br>";
//echo $ph;
$sq=mysql_query("INSERT into db_table3(`fname`,`lname`,`phone_number`) VALUES('$a','$b','$ph')");
$re=mysql_query($sq,$con);
}
}
fclose($h);
No comments:
Post a Comment