-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.php
More file actions
71 lines (49 loc) · 2.12 KB
/
function.php
File metadata and controls
71 lines (49 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
function get_ma() {
require "connection.php";
$q_result = mysqli_query($conn,"SELECT MAX(dthoai_ma ) as maxm FROM dien_thoai")
or die("Query failed: " . mysqli_error($conn));
//echo "maxm: " . mysql_result($q_result, 0, "maxm") . "; ";
while($row=mysqli_fetch_assoc($q_result)){
$id=$row['maxm'];
}
return $id+ 1;
}
function get_data(){
require "connection.php";
$q_result = mysqli_query($conn,"SELECT * FROM dien_thoai")
or die("Query failed: " . mysqli_error($conn));
}
function dropdown_options($tb_name, $value_col, $text_col, $none=false, $default='') {
require "connection.php";
if ($none)
echo "<option value=''></option>\n";
$query = "SELECT " . $value_col . ", " . $text_col .
" FROM " . $tb_name;
$q_result = mysqli_query($conn,$query)
or die("Query failed: " . mysqli_error($conn));
//generate list of options
while ($row = mysqli_fetch_array($q_result)) {
echo "<option value='", $row[0], "' ";
if ($row[0] == $default)
echo "selected";
echo ">", $row[1], "</option>\n";
}
}
function dropdown_options1($tb_name, $value_col, $text_col,$diachi,$id, $none=false, $default='') {
require "connection.php";
if ($none)
echo "<option value=''></option>\n";
$query = "SELECT " . $value_col . ", " . $text_col .
" FROM " . $tb_name . "where ". $diachi."=".$id;
$q_result = mysqli_query($conn,$query)
or die("Query failed: " . mysqli_error($conn));
//generate list of options
while ($row = mysqli_fetch_array($q_result)) {
echo "<option value='", $row[0], "' ";
if ($row[0] == $default)
echo "selected";
echo ">", $row[1], "</option>\n";
}
}
?>