39 lines
851 B
PHP
39 lines
851 B
PHP
<?php
|
|
require_once "../config.php";
|
|
|
|
$sql = "
|
|
SELECT
|
|
categoria.id,
|
|
categoria.clave,
|
|
categoria.padre,
|
|
categoria.nombre,
|
|
categoria.imagen,
|
|
categoria.descripcion
|
|
FROM
|
|
categoria
|
|
WHERE
|
|
categoria.habilitado = 1 AND categoria.padre = 1
|
|
";
|
|
|
|
global $link;
|
|
dbConnect();
|
|
$result = mysqli_query($link, $sql);
|
|
$return = new stdClass();
|
|
if ( mysqli_num_rows($result) <= 0 ) {
|
|
$return->code = "0";
|
|
$return->msg="Sin cursos";
|
|
}else{
|
|
$return->code = "1";
|
|
$return->msg="cursos";
|
|
$return->datos = [];
|
|
while ($row = mysqli_fetch_array ($result)){
|
|
$img = trim((string)$row["imagen"]);
|
|
if ($img !== '' && !preg_match('~^(https?:)?//~i', $img)) { $img = rtrim($CFG->wwwroot, '/') . '/' . ltrim($img, '/'); }
|
|
$row["imagen"] = $img;
|
|
$return->datos[] = $row;
|
|
}
|
|
}
|
|
echo json_encode($return, JSON_UNESCAPED_UNICODE);
|
|
mysqli_free_result($result);
|
|
exit;
|
|
?>
|