:: Forum >> Version 1 >>

ActiveWidgets grid with / con PHP

More information on this topic is available in the documentation section: /active.howto.load.xml/.

Hola, estoy intentando pasar el resultado de una consulta mysql realizada en php y busco implementar el resultado de esa variable en el AW Grid. Algún consejo? Gracias por anticipado.

Hi, I'm trying copy the result of a select (mysql) in the AW Grid. Help please!
Thursday, August 11, 2005
http://activewidgets.com/javascript.forum.3371.3/php-without-mysql.html
Thursday, August 11, 2005
//Esta primera parte te muestra como debe ser el array en el
//cual se almacena el Objeto del datagrid
/*
var myData = [
["MSFT","Microsoft Corporation", "314,571.156", "32,187.000"],
["ORCL", "Oracle Corporation", "62,615.266", "9,519.000"],
["SAP", "SAP AG (ADR)", "40,986.328", "8,296.420"],
["CA", "Computer Associates Inter", "15,606.335", "3,164.000"],
["ERTS", "Electronic Arts Inc.", "14,490.895", "2,503.727"]
];
*/
////No debes copiar el codigo de arriba solo es para mostrate como
//se da formato.

print '
<script type="text/javascript">
var myData = new Array();';
//Realizas la consulta
$query = "SELECT * FROM tabla";
$res = mysql_query($query);

while($res = mysql_fetch_array($result, MYSQL_ASSOC)){
print '"'.$res['campo1'].'","'.$res['campo2'].'"'."\n";
}

$filas = mysql_num_rows($res);
print '
var obj = new Active.Controls.Grid;

obj.setColumnProperty("count", 2);
obj.setRowProperty("count", '.$filas.');
obj.setDataProperty("text", function(i,j){return myData[i][j]});

document.write(obj);

';
print '</script>';

//Espero te funcione por que no lo probe.
//Pero creo que esa es la forma correcta de hacerlo
//Nunca use este objeto pero por lo visto es muy simple de usarlo
//Espero en un futuro no muy lejano usando este objeto crear
//un datagrid en el cual se pueda actualizar, borrar y adicionar nuevos
//registros en el datagrid usando AJAX y DOM
Boris Barroso
Thursday, August 11, 2005
//perdon error
//La parte que es asi
while($res = mysql_fetch_array($result, MYSQL_ASSOC)){
print '"'.$res['campo1'].'","'.$res['campo2'].'"'."\n";
}
//debe ser de la siguiente forma
$i=0;
$filas = mysql_num_rows($res);

while($res = mysql_fetch_array($result, MYSQL_ASSOC)){
print 'myData['.$i.'] = new Array()';
if($i+1<$filas)$coma=',';
else $coma='';
print '["'.$res['campo1'].'","'.$res['campo2'].'"]'.$coma."\n";
$i++;
}
Boris Barroso
Thursday, August 11, 2005
Gracias por todo Boris
José Luis Martí
Friday, August 12, 2005
<? include("connection.inc");

print '<script> ';


$qry = "select a.code, a.fname, a.lname, a.lab, a.ppno, a.visano, a.visadate, a.doi, a.gamca_id, b.name, a.accept, a.uniqses from " . $_SESSION['datayear']. " a, company b where a.agency = b.compcode ". $condition . " order by substring(a.code,3)";
$result=mysql_query($qry);
$cstring = ' var myData = [' ;
$tt = mysql_num_rows($result);
while($row=mysql_fetch_array($result)){
$cstring=$cstring . '["'. $row['code'] .'", "<a href=test.php?'.$row['code'].'>' . $row['fname'] .'</a>", "' . $row['lname'] . '", "'. $row['lab'] . '", "' . $row['ppno'] .'","'. $row['visano'] . '", "' . $row['visadate'] .'","' .$row['doi']. '","'.$row['gamca_id']. '","'.$row['name']. '","<a href=singleview.php?' . $row['uniqses'].' target=_blank>' ;

$filename = "2006/" . substr($row['ppno'], -1, 1) ."/". $row['ppno'] . '.GIF' ;
if (file_exists($filename)){
$exist = $row['accept'] ;
}
else{
$exist="<B> ". $row['accept'] . "</B>";
}
$cstring=$cstring . $exist .'</a>"],' ;

}
$cstring=substr($cstring,0,strlen($cstring)-1) ."]; " ;
print $cstring ;
?>





var myColumns = [
"Code", "First Name", "Last Name", "Clinic", "Visa No", "Visa Date","Passport","DOI","Gamca Id","Agency", "A"];
</script>
varsha shakya, varsha_shakya@yahoo.com
Tuesday, January 31, 2006



This topic is archived.

Back to /active.howto.load.xml/

Documentation:

Forum search