-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
One mysql table doesn't update but the others do it #31
Comments
This is the one that works (loaddata.php) <?php session_start();
/*
* examples/mysql/loaddata.php
*
* This file is part of EditableGrid.
* http://editablegrid.net
*
* Copyright (c) 2011 Webismymind SPRL
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://editablegrid.net/license
*/
/**
* This script loads data from the database and returns it to the js
*
*/
require_once('config.php');
require_once('EditableGrid.php');
/**
* fetch_pairs is a simple method that transforms a mysqli_result object in an array.
* It will be used to generate possible values for some columns.
*/
function fetch_pairs($mysqli,$query){
if (!($res = $mysqli->query($query)))return FALSE;
$rows = array();
while ($row = $res->fetch_assoc()) {
$first = true;
$key = $value = null;
foreach ($row as $val) {
if ($first) { $key = $val; $first = false; }
else { $value = $val; break; }
}
$rows[$key] = $value;
}
return $rows;
}
// Database connection
$mysqli = mysqli_init();
$mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5);
$mysqli->real_connect($config['db_host'],$config['db_user'],$config['db_password'],$config['db_name']);
// create a new EditableGrid object
$grid = new EditableGrid();
/*
* Add columns. The first argument of addColumn is the name of the field in the databse.
* The second argument is the label that will be displayed in the header
*/
$grid->addColumn('id_muestra', 'Clave', 'string', fetch_pairs($mysqli,'SELECT id,clave FROM muestras WHERE muestras.id_salida='.$_SESSION['idsalida'] ),true);
$grid->addColumn('especie', 'Especie', 'string');
$grid->addColumn('colector', 'Colector', 'string');
$grid->addColumn('perforaciones', 'Perforaciones', 'boolean');
$grid->addColumn('vermes', 'Vermes', 'boolean');
$grid->addColumn('ectoparasitos', 'Ectoparásitos', 'boolean');
$grid->addColumn('hongos_bacterias', 'Hongos o Bacterias', 'boolean');
$grid->addColumn('deformidades', 'Deformidades', 'boolean');
$grid->addColumn('lesiones', 'Lesiones', 'boolean');
$grid->addColumn('olores', 'Olores', 'boolean');
$grid->addColumn('observaciones', 'Observaciones', 'string');
$grid->addColumn('verificado', 'Verificado', 'boolean');
$grid->addColumn('borrar', 'Borrar', 'boolean');
$result = $mysqli->query('SELECT * FROM biologicos WHERE biologicos.id_muestra IN (SELECT id FROM muestras WHERE muestras.id_salida='.$_SESSION['idsalida'].' ) or biologicos.id_muestra<0 '); // LIMIT 100'
$mysqli->close();
// send data to the browser
$grid->renderXML($result); This is the one that not <?php session_start();
/*
* examples/mysql/loaddata.php
*
* This file is part of EditableGrid.
* http://editablegrid.net
*
* Copyright (c) 2011 Webismymind SPRL
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://editablegrid.net/license
*/
/**
* This script loads data from the database and returns it to the js
*
*/
require_once('config.php');
require_once('EditableGrid.php');
// create a new EditableGrid object
$grid = new EditableGrid();
/**
* fetch_pairs is a simple method that transforms a mysqli_result object in an array.
* It will be used to generate possible values for some columns.
*/
function fetch_pairs($mysqli,$query){
if (!($res = $mysqli->query($query)))return FALSE;
$rows = array();
while ($row = $res->fetch_assoc()) {
$first = true;
$key = $value = null;
foreach ($row as $val) {
if ($first) { $key = $val; $first = false; }
else { $value = $val; break; }
}
$rows[$key] = $value;
}
return $rows;
}
// Database connection
$mysqli = mysqli_init();
$mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5);
$mysqli->real_connect($config['db_host'],$config['db_user'],$config['db_password'],$config['db_name']);
#$grid->addColumn('id_muestra', 'Clave', 'string', fetch_pairs($mysqli,'SELECT id,clave FROM muestras WHERE muestras.id_salida='.$_SESSION['idsalida'] ),true);
$grid->addColumn('identificador', 'ID', 'integer', NULL, true);
$grid->addColumn('id_muestra', 'muestra', 'integer', NULL, true);
$grid->addColumn('id_submuestra', 'submuestra', 'integer', NULL, true);
$grid->addColumn('id_laminilla', 'laminilla', 'integer', NULL, true);
$grid->addColumn('nombre', 'Nombre', 'string', NULL, true);
$grid->addColumn('localizacion', 'localizacion', 'string', NULL, true);
$grid->addColumn('observaciones', 'Observaciones', 'string', NULL, true);
$grid->addColumn('verificado', 'Verificado', 'boolean', NULL, true);
$grid->addColumn('borrar', 'Borrar', 'boolean', NULL, true);
$result = $mysqli->query('SELECT * FROM fotografias where 1'); // LIMIT 100'
$mysqli->close();
// send data to the browser
$grid->renderXML($result); |
This are the js files, the one that works
This is the one that doesnt work
|
I tried the demo exactly as it is and still dont work I change only the config.php file in order to add the db info and the table doesnt appear |
Please check this url /loaddata.php Please share, what data it has?? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a DB which Im editing with this but one of the tables doesnt work and I really don't know why, the one that works is biologicos and fotografias doesn't
The text was updated successfully, but these errors were encountered: