Created
May 19, 2015 07:39
-
-
Save basicssm/39872cad418ddc7300c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once(__DIR__.'/../lib/settings.php'); | |
require_once(__DIR__.'/../lib/conexion.php'); | |
if(isset($_POST['table'])){ | |
$table = $_POST['table']; | |
$query = "select * from ".$table." order by orden asc;"; | |
if ($result = $mysqli->query($query)){ | |
$info_campo = $result->fetch_fields(); | |
$data = array(); | |
while($object = $result->fetch_object()) | |
{ | |
$dataItem = new stdClass(); | |
foreach($info_campo as $info) | |
{ | |
$col = $info->name; | |
$dataItem->$col = utf8_encode($object->$col); | |
} | |
$data[] = $dataItem; | |
} | |
$result = new stdClass(); | |
$result->ok = 'true'; | |
$result->data = $data; | |
echo json_encode($result); | |
} | |
else | |
{ | |
$result = new stdClass(); | |
$result->ok = 'false'; | |
$result->data = 'Database error'; | |
echo json_encode($result); | |
} | |
} | |
else{ | |
$result = new stdClass(); | |
$result->ok = 'false'; | |
$result->data = 'Error'; | |
echo json_encode($result); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment