huyen_lib
<?php
function db_init() {
$connect = mysql_connect ('localhost', 'root', '1');
mysql_select_db ('test', $connect);
mysql_query ("create table if not exists huyen (id_tinh char (2) not null, id char (2) not null, name char (64), primary key (id_tinh, id))");
}
function read_some ($matinh, $ma='', $ten='') {
return mysql_query ("select * from huyen where id_tinh = '$matinh' and id like '%$ma%' and name like '%$ten%'");
}
function read_row ($matinh, $ma='') {
return mysql_query ("select * from huyen where id_tinh='$matinh' and id='$ma'");
}
function delete_row ($matinh, $ma) {
mysql_query ("delete from huyen where id_tinh='$matinh' and id='$ma'");
}
function update_row ($matinh, $key, $ma, $ten) {
mysql_query ("update huyen set id='$ma', name='$ten' where id_tinh='$matinh' and id='$key'");
}
function add_row ($matinh, $ma, $ten) {
mysql_query ("insert into huyen (id_tinh, id, name) values ('$matinh', '$ma', '$ten')");
}
?>
Bạn đang đọc truyện trên: Truyen247.Pro