Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $total = get_query('Curs', 'cursos', 'NULL', 'NULL', 1); //retorna el numero total de cursos
- $mostrat = get_query('Curs', 'cursos', 'NULL', 'NULL', 2);
- for ($i = 0; $i<= $total; $i++)
- {
- echo "<option>$mostrat[$i]</option>";
- }
- ?>
- function get_query($selection, $table, $column, $data, $option)
- {
- $configs = include("config.php"); //archivo de configuraciones basico
- $link = mysqli_connect($configs['ip'], $configs['username'], $configs['password'], $configs['bbdd']);
- switch ($option)
- {
- case 0:
- $sql = "SELECT $selection FROM $table WHERE $column = '$data'";
- break;
- case 1:
- $sql = "SELECT COUNT(*) as $selection from $table";
- break;
- case 2:
- $sql = "SELECT $selection FROM $table";
- break;
- }
- $result = mysqli_fetch_assoc(mysqli_query($link, $sql));
- return $result[$selection];
- mysqli_close($link);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement