forked from agarzon/JQombo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.php
More file actions
53 lines (47 loc) · 1.46 KB
/
class.php
File metadata and controls
53 lines (47 loc) · 1.46 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
<?php
/**
* JQombo: Combo dependiente AJAX con todas las ciudades y estados de Venezuela
* @author Alexander Garzon
*/
class JCombo {
/**
* Conecta a MySQL
* @param string $dbhost
* @param string $dbuser
* @param string $dbpass
* @param string $dbname
*/
public static function conectar($dbhost, $dbuser, $dbpass, $dbname){
$link = @mysql_connect($dbhost, $dbuser, $dbpass) or die("ERROR DE CONEXION A BASE DE DATOS");
@mysql_select_db($dbname) or die("ERROR DE CONEXION A BASE DE DATOS");
}
/**
* Genera input select con los estados
*/
public static function ver_estados(){
$result = @mysql_query("SELECT * FROM estados;");
$estados = "<select name=\"estados\" id=\"estados\">\n\r";
$estados .= "<option value=\"0\"> </option>\n\r"; // Default
while ($array = mysql_fetch_array($result)){
$estados .= "<option value=\"$array[id]\">$array[estado]</option>\n\r";
}
$estados .= "</select>\n\r";
echo $estados;
}
/**
* Genera input select con los estados
* @param integer $cod
*/
public static function ver_ciudades($cod = 0){
$result = mysql_query("SELECT * FROM ciudades WHERE cod = '$cod';");
//var_dump($result);exit;
$ciudades = "<select name=\"ciudades\" id=\"ciudades\">\n\r";
$ciudades .= "<option value=\"0\"> </option>\n\r"; // Default
while ($array = mysql_fetch_array($result)){
$ciudades .= "<option value=\"$array[id]\">$array[ciudad]</option>\n\r";
}
$ciudades .= "</select>\n\r";
echo $ciudades;
}
}
?>