Load data from database

Hi everyone,

thanks to Alexandra i resolved the problem of dataview but now i have a little problem with loading data.

i load a php file from dataview.load but the strange thing is that if i modify my database, the dataview doesn’t update the data, even though i close the browser and i open it again.

if instead i open directly the php file i see the xml file created and at this point loading again the page i see the data correctly in the dataview.

what could be the reason?

the php file that i have is this one:
require(“…/conn_codebase/dataview_connector.php”);

$conn=mysql_connect(“localhost”,“root”,“”);
$database = mysql_select_db(“clown”);
$data = new DataViewConnector($conn,“MySQL”);

$data->render_sql(“SELECT * from membri”,“codicefiscale”,“indirizzo,cap,citta”);
mysql_close();

thanks for your help

Hi,

possibly it is caching. Try to add the random parameter to the request:

dataview.load(url+"?rs="+(new Date()).getTime());

i tried to load a random parameter but nothing.

i must always open the php from browser and then it’s updated.

is there a solution for that?

On components level - there is no way to cache data between page reloadings.
So problem must be somewhere in server’s configuration.

what could be the problem?

i connect to the database once to load name of members in a grid and here no problem.
i close the connection once loaded.

then when i click in a row of my grid i load again informations from database and here it’s not update itself.

or better data are taken correctly but if i don’t generate the xml file opening the php file into the browser data are not updated.

don’t know how resolve the problem even in server side because it’s the same thing of the first step, when i load from grid and there it works fine.

Are you using any php frameworks of db middleware?
Normally if you are using just php and connects directly to DB - all must work smoothly. If you are using some complex framework|setup - it possible that some of layers introducing a caching.

hi Stanislav,

and thanks for support,

i use easyphp to be able to have a localhost, but i don’t think the problem is this, because as i told you, the members of the grid works perfectly.

another strange fact is that if i open the browser the forst time everything work at 100% (i mean that correct data are loaded regarding each memebr) so the php file works fine and there are not errors.
But if i change something in the database and i update the browser nothing happens.
to see the changes i must or close and open again the browser or open the php file in the browser and then load again the index.html page.

it’s very strange…

I discovered a thing that maybe can help you to understand the error and help me to resolve it.

i don’t write you all the functions a wrote but just the once i use to load data in the dataview

function row (id,ind) {

var indice = grid.getRowIndex(id);

SetCookie("indice", grid.getRowIndex(id));

dataview.load("php/info_clown.php");

}

function SetCookie(name, value) {
var todayDate = largeExpDate = new Date();
largeExpDate.setTime(todayDate.getTime() + 10 * 1000); //si stabilisce quando scadono i cookies con il tempo espresso in mille secondi
document.cookie = name + “=” + escape(value) + “; expires=” + largeExpDate.toGMTString(); //scrive il cookies (name = nome del cookie value = valore del coockie)
}

as you can see i use cookies to get the variable from js to php.

and here below the php file:

require("…/conn_codebase/dataview_connector.php");

$conn=mysql_connect(“localhost”,“root”,"");
$database = mysql_select_db(“clown”);
$query = “SELECT * FROM membri”;
$result = mysql_query($query,$conn);
$i = 0;
$data = new DataViewConnector($conn);

$indice = $_COOKIE[“indice”];

while($i <= $indice)
{
$row = mysql_fetch_array($result);
$i++;
}

$codicefisc = $row[“codicefiscale”];
$data->render_sql(“SELECT * FROM membri WHERE codicefiscale = ‘$codicefisc’”,“codicefiscale”,“codicefiscale,indirizzo,citta,provincia,cap,email,telefono,cellulare,sesso,data”);

the thing i noticed is that if i show a popup window in row function such as alert(document.cookie), the corret index of the row is showed, but if i modify my php file no changes are showed. even though i create an error such as writing Whle() nothing appens. this means that the file php is loaded just once when i open the browser and no more. neither if i update the page.

if i clow the browser and open it again the first one data is loaded correctly and the nothing… no more php file is loaded, the function row() works always but instruction dataview_load() for some reason not.

Could you help me if these informations?

Hello,

does php/info_clown.php return the updated data ?

It seems that there is no need to use cookies:

function row (id,ind) {

var indice = grid.getRowIndex(id);

//SetCookie(“indice”, grid.getRowIndex(id));

dataview.load(“php/info_clown.php?indice=”+indice);
}

in the php script:

//$indice = $_COOKIE[“indice”];
$indice = $_GET[“indice”];

thanks Alexandra,

your solution worked but just for 2 clicks, if i select more than 2 rows data are not loaded anymore.

is there a way to check variables in php? because if i write echo “ciao” i don’t see it anywhere.
So i can check each line of php code if works fine.

For Js i use alert(); to check variable but in php i can’t see the variable values.

any suggestion?

thank you so much

is there a way to check variables in php?

You may try to use error_log function :

php.net/manual/en/function.error-log.php

Hi alexandra,

i tried some experiments and i found the way to show the error_log.

but there is still something not working… don’t know if it’s a bug or what.

in my database i have 3 records and are loaded in the grid. Then i click on row of the grid and i display informations. Everything works fine if i click each row for the first time.

For example:

step1: click on row1 -> i display data informations OK!!!
step2: click on row3 -> i display data informations OK!!!
step3: click on row2 -> i display data informations OK!!!
step4: i click again row3 or row2 or row1 -> informations don’t change anymore WRONG!!!

infact my php file is not loaded anymore because no error_log is created.

why after i clicked each row i can’t load the php file anymore?

thanks

Hello,

if you are sure that the problem is caused by our component, please provide the completed demo that allows to recreate the problem locally:
docs.dhtmlx.com/doku.php?id=othe … leted_demo