reset and begin
7/07/2009

trailer evian funny






logo in file html

<link rel="shortcut icon" href="đường dẫn logo" type="image/x-icon"/>

download data in php

$strcnn=mysql_connect("localhost","root","");

mysql_select_db("demodata",$strcnn);



$querry="select * from data where id=1";

$result=mysql_query($querry);

list($id,$filecontent,$filesize,$filename)=mysql_fetch_array($result);

header("Content-Length: $filesize");

header("Content-Type: application/octet-stream");

header("Content-Disposition: attachment; filename=\"$filename\"");

echo $filecontent;



?>

upload using ftp +FileZilla_3.2.4.1_win32-setup.exe

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<?php

$ftpconn=ftp_connect("192.168.1.7") or die ("ke^'t no^'i hong");

ftp_login($ftpconn,"demo","123456") or die("dang nhap that bai");

$target='new/';

$fileup=$_FILES['upload']['name'];

$target=$target.$fileup;



if(move_uploaded_file($_FILES['upload']['tmp_name'],$target)==true){

ftp_put($ftpconn,$fileup,$target,FTP_BINARY) or die("loi");

}

else{

echo"upload loi";

}?>

redirect in php

header('refresh:5;url=link.php');// 5 s sẽ chuyển trang

header('location:link.php');

dùng thẻ meta của html

echo('<meta http-equiv=refresh content:5; url:link.php' />');



using class connect to data in php

ex: class in php
<?php

class db

{

var $host,$user,$pass,$data;

var $cnn;

function __construct($host,$user,$pass,$data)

{

$this->host=$host;

$this->user=$user;

$this->pass=$pass;

$this->data=$data;



}

function ketnoihost(){

$this->cnn=mysql_connect($this->host,$this->user,$this->pass) or die (mysql_error());

echo"ket noi host ok";

}

function ketnoidb(){

mysql_select_db($this->data,$this->cnn) or die (mysql_error());

echo "ket noi data thanh cong";

}





}

$d=new db("localhost","root","","mysql");

$d->ketnoihost();

$d->ketnoidb()

class in php

using class in php
<?php

class sinhvien{

var $toan,$ly,$hoa;

function __construct($toan,$ly,$hoa)

{

$this->toan=$toan;

$this->ly=$ly;

$this->hoa=$hoa;



}

var $tb;

function tinhdiem(){

$toan=$this->toan;

$ly=$this->ly;

$hoa=$this->hoa;

$this->tb=($toan+$ly+$hoa)/3;

echo "sinh vien co tong diem".$this->tb;

}

function xeploai()

{

$xl=$this->tb;

if($xl<5){ echo " trung binh" ;}

else if ($xl>5 &&$xl<7 ){echo " trung binh kha ";}

else echo"gioi";

}

}

$a=new sinhvien(4,7,15);

$a->tinhdiem();

$a->xeploai();



?>

check user using ajax

<?php $strcnn=mysql_connect("localhost","root",""); mysql_select_db("data",$strcnn);
$user=$_POST['user']; $pass=$_POST['pass'];
$strq="select * from tbluser where user='$user' AND pass='$pass'";
$result=mysql_query($strq); echo mysql_num_rows($result);
if(mysql_num_rows($result)<>0) { echo "helo:".$user; } else { echo "<a href='bai141.php'> quay lai</a>"; } ?>

7/06/2009

function split remove string

string strchuoi = "helo ai do a o do vay" ; ex:
int n =Convert.ToInt32(strchuoi.Length.ToString());
string[] mang= strchuoi.Split(' ');
int sodoan=0; count
foreach(string y in mang)
{
sodoan=sodoan+1;
}

Response.Write(mang[sodoan-1]);
using trim cut space in string

up link to google

http://www.google.com.vn/addurl/?continue=/addurl
SEO add url in GOOGLE

ajax + caculator simple

<html> <head>  </head>   <body>
<script language="javascript" type="text/javascript">
function ajax() { var ajaxRequest; try{ ajaxRequest = new XMLHttpRequest(); }
catch(e){ try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
catch(e){ try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); }
catch(e){ alert("Error"); } } } ajaxRequest.onreadystatechange = function()
{ if(ajaxRequest.readyState == 4) { document.myForm.kq.value = ajaxRequest.responseText; }
} var so1 = document.getElementById("so1").value;
var so2 = document.getElementById("so2").value;
var pt = document.getElementById("pt").value;
ajaxRequest.open("GET","tinhtoan.php?so1="+so1+"&pt="+pt+"&so2="+so2,true);
ajaxRequest.send(null); } < /script>
<form name="myForm"> So 1 <input type="text" id="so1"> So 2
<input type="text" id="so2">
Chon phep tinh : <select id="pt" onChange="ajax()">
<option value="cong">Cong</option>
<option value="tru">Tru</option>
<option value="nhan">Nhan</option>
<option value="chia">Chia</option>
</select> Ket qua
<input type="text" id="kq">
</form> </body> </html>

javascsript interger parseint

parseInt(string)
parseInt(abs23) -> 23
or eval(string)

ajax simple

function ajax(){ var ajaxrequest; ajaxrequest=new XMLHttpRequest();
ajaxrequest.onreadystatechange=function()
{ if(ajaxrequest.readyState==4)
{ document.myform.kq.value=ajaxrequest.responseText; } }
var so1=document.getElementById('so1').value;
var so2=document.getElementById('so2').value;
ajaxrequest.open("Get","ketqua.php?so1="+so1+"&so2="+so2,true);
ajaxrequest.send(null); }
</script> <form name="myform">
<input type="text" id="so1" />
<input type="text" id="so2" />
<input type="text" id="kq" />
<input type="button" value="ok" onclick="ajax()" /> </form>

remove logo vituremart in joomla

components\com_virtuemart\themes\default\templates\common\minicart.tpl.php

<?php if(!$vmMinicart) { ?> <a href="http://virtuemart.net/" target="_blank"> <img src="<?php echo $mm_action_url ?>components/com_virtuemart/shop_image/ps_image/menu_logo.gif" alt="VirtueMart" width="80" border="0" /></a> <br /> <?php }

paging in php

<?PHP $perpage=4; $strcnn=mysql_connect("localhost","root","");
mysql_select_db("data",$strcnn); $qs="select * from sinhvien";
$result=mysql_query($qs); $total=mysql_num_rows($result);
// tong so ban ghi echo("tong ban ghi :".$total."<br>");
$numofpage=ceil($total/$perpage);//lam tron so trang
if($_GET['page']=="") {//kiem tra $x=0; }
else{ $x=($_GET["page"]-1)*$perpage; }
$qs1="select * from sinhvien limit $x,$perpage";
//khoang ban ghi can lay $result1=mysql_query($qs1);
while($row1=mysql_fetch_array($result1)) {
echo("id: ".$row1['id']."hoten ".$row1['ten']."<br>"); }
echo "trang :"; for($i=1;$i<=$numofpage;$i++)
{ echo("<a href=bai10.php?page=".$i.">".$i."</a>".""); }
echo("<br>"); ?> $lui=($_GET["page"]-1); $tien=($_GET["page"]+1);
if($tien<=$numofpage) { echo("<a href=bai10.php?page=".$tien.">tien</a>"); }
if($lui>0&&$lui<$numofpage) { echo("<a href=bai10.php?page=".$lui.">lui</a>"); }

image in php

<?php $conn=mysql_connect("localhost","root",""); $mystr=mysql_select_db("data",$conn) or die("loi"); $qs="select * from images"; $result=mysql_query($qs)or die('loi'); $a=1; echo("<table border='5px' width='800'>"); echo("<tr>"); while($row=mysql_fetch_array($result)) { echo("<td align='center'>"); echo("<img src='".$row['link']."' width='150' height='100px'>"); echo("</td>"); if($a%4==0){ echo("</tr><tr>"); } $a=$a+1; } echo("</tr>"); echo("</table>"); ?>

 


file upload

<form action="anh.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> upload <?php for($i=0;$i<3;$i++)


{ ?> <input type="file" name="up<?php echo $i ?>" id="up" /> <?php } ?> <input type="submit" value="upload" /> </form>

anh.php

<?php $target="up6/"; $conn=mysql_connect("localhost","root",""); $mystr=mysql_select_db("data",$conn) or die("loi");


if(is_dir($target)==false) { mkdir($target); } for($i=0;$i<3;$i++) { $link=$target.$_FILES['up'.$i]['name']; if(move_uploaded_file($_FILES['up'.$i]['tmp_name'],$link)==true) { $thongbao="up thanh cong"; }


$qs="insert into images (link) values ('$link')"; mysql_query($qs) or die ('loi'); $thongbao2="insert thanh cong"; }


echo($thongbao); echo($thongbao2); ?>


update data php code

update.php
<?php
include('ketnoi.php');
$ht=$_POST['hoten'];
$tp=$_POST['tp'];
$id=$_GET['id'];
$gt=$_POST['gioitinh'];
$qup="update member set hoten='$ht',thanhpho='$tp',gioitinh='$gt' where id='$id'";
mysql_query($qup);
echo("up ok".$tp.$ht.$id);
?>

update ...

<?php
include("ketnoi.php");
$id=$_GET["id"];
$qsm="select *from member where id=$id";
$qstp="select *from thanhpho";
$result=mysql_query($qsm,$conn);
while($row=mysql_fetch_array($result))
{
echo "";
echo"";
echo"";
$resulttp=mysql_query($qstp,$conn);
while($rowtp=mysql_fetch_array($resulttp))
{
echo"<option value=".$rowtp['id']."";
if($rowtp['id']==$row['thanhpho']){
echo " selected ";
}
echo ">".$rowtp['tp']."";
}
echo"
";
echo "nam <input type='radio' name='gioitinh' value='0'";
if($row['gioitinh']==0)
{
echo " checked ";
}
echo " />";

echo "nu <input type='radio' name='gioitinh' value='1'";
if($row['gioitinh']==1)
{
echo " checked ";
}
echo " />
";

echo"";
echo"";
}

?>

menu mutil level

<style type="text/css"> .menuchinh{ float:left; border-color:#00CC33; border-style:groove; border:2px; } .menuphu{ float:left; border-color:#00CC33; border-style:groove; border:2px; } </style> <script language="javascript"> function show(id) {var mem="menu"+id document.getElementById(mem).style.display="block"; } function hide(id) {var mem="menu"+id document.getElementById(mem).style.display="none"; } </script> <body> <div style="height:400px" class="menuchinh"> <ul><li onmouseover="show(1)" onmouseout="hide(1)" ><a href="#">trang chu</a></li> <li onmouseover="show(2)" onmouseout="hide(2)" ><a href="#">trang chu</a></li> </div> <div style="height:100px" class="menuphu"> <div id="menu1" style="display:none"> <ul> <li><a href="gghf">menu 1 1</a></li> <li><a href="gghf">menu 1 1</a></li> <li><a href="gghf">menu 1 1</a></li> </ul> </div> <div id="menu2" style="display:none"> <ul> <li><a href="gghf">menu 1 1</a></li> <li><a href="gghf">menu 1 1</a></li> <li><a href="gghf">menu 1 1</a></li> <li><a href="gghf">menu 1 1</a></li> <li><a href="gghf">menu 1 1</a></li> <li><a href="gghf">menu 1 1</a></li> </ul></div> </div>

menu simple

<pre><script language="javascript">

function chane(obj)

{

var sid=document.getElementById(obj);

if(sid.style.display=='block')

{

sid.style.display='none';

}

else

{

sid.style.display='block';

}

}

</script>


<div id="menu1" onclick="chane('sub1')">mainmenu</div>

<span id="sub1" style="display:none">

- <a href="#"> link 4</a><br />

- <a href="#">link 3</a><br />

- <a href="#">link 2</a><br />

- <a href="#">link 1</a>

</span>

<div id="menu2" onclick="chane('sub2')">mainmenu</div>

<span id="sub2" style="display:none">

- <a href="#"> link 4</a><br />

- <a href="#">link 3</a><br />

- <a href="#">link 2</a><br />

- <a href="#">link 1</a>

</span>

</pre>


Code count time

<pre><script type="text/javascript">

var x=10,y=10;

var timeout;

function loadsrc()

{

var objhi;

objhi=document.getElementById('obj1');


objhi.style.position="relative"; // move

objhi.style.top=100+y+"px";// up +1

y++;


var d = new Date();

var mes=d.getSeconds();

var h=d.getHours();

var minute=d.getMinutes();

var thang=d.getMonth();

var nam=d.getYear();

window.status="gio"+h+"phut"+minute+"giay"+mes+"thang:"+thang+nam;

timeout=setTimeout(loadsrc,100);// for with functionsetTimeout

}

html

<img id="obj1" src="co.jpg" height="100" width="100" /></img>

<a onclick="loadsrc()">chay</a>

<a onclick="dungsrc()">dung</a>

</pre>


using code javascript play music on FF và IE

<pre>function loadnhac(obj) { var flash; var media=document.getElementById('media'); var browser=navigator.appName; if(browser=="Microsoft Internet Explorer") { flash = '<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95">'; //kiem tra trinh duyet

flash += '<param name="src" value="' + obj+ '">'; flash += '<param name="autoStart" value="True"></object>'; media.innerHTML = flash; } else{ flash = '<embed type="video/x-ms-wmv" heigth="300px" width="230px" wmode="tranparent" src="' +obj + '"></embed>'; media.innerHTML = flash; }


<div id="media">

</div>

<a onclick="loadnhac('a.mp3')">bai 1</a>

<a onclick="loadnhac('b.mp3')">bai 2</a>

truyen tham so

</pre>


using function (preg_match)



$f = fopen("http://gamethu.vnexpress.net/News/Dang-choi/", "rb"); // url using
$contents = '';

while (!feof($f)) {

$contents .= fread($f,1000);

}

fclose($f);

$mau = '//si';

if(preg_match($mau,$contents,$str))

{ $xuat =("".$str[0]."");

echo ($xuat);

}

else{

echo("loi");

}


php simple sql querry

select * from sinhvien where hoten like a
update sinhvien set hoten=new where hoten like a
delete from sinhvien where hoten like a
insert into sinhvien (hoten) values(giatri)

php simple connect data

$conn=mysql_connect("localhost","root","");// host server
mysql_select_db("demodb",$conn)or die("ket noi that bai"); //data
echo("ket noi thanh cong");

php simple option of html

  <?php   $conn=mysql_connect("localhost","root","");

$mystr=mysql_select_db("demo",$conn) or die("loi");

$qs="select * from thanhpho"; $result=mysql_query($qs) or die("loi "); ?>

<?php while($row=mysql_fetch_array($result))

{ echo"".$row['tentp'].""; }?>

php simple delete data

---------------------------------------------------------- data : demodb server:localhost table:sinhvien (id,hoten,tuoi)
-----------------------------------
xuly.php
----------------------------------------------------------------------------
hien.php <?php $conn=mysql_connect("localhost","root",""); mysql_select_db("demodb",$conn); $qsl="select * from sinhvien"; $result=mysql_query($qsl); while($row=mysql_fetch_array($result)) { echo($row["id"].$row["hoten"].$row["tuoi"]."[html:a href=xuly.php?id=$row[id]]delete
"); } mysql_close($conn); ?>

List

Profiles Information


About me : Nothing is 1 vài thứ - 1985

Places I've Lived : I Hà Nội

Home Page : http://www.shimivn.blogspot.com/

Think : 1:1000000000

Languages spoken : Vietnamese,English.

Mobile : sony C2305

dell : i3-Ram 3GB- HDD 250GB .