Ayuda con el Grid con PHP y BD MySql
Hola me podrian ayudar kisiera hacer busquedas de registros en mi Grid con PHP. Mi Grid ligado a una Base de Datos MySql. Ayudenme porfa les dejo mi Script que muestra los registros de la Base de Datos.
<?php
$connection = @mysql_connect('localhost', ' ', ' ');
@mysql_select_db('domini43_clientes', $connection);
$query = 'SELECT * FROM cliente LIMIT 0,10';
$dataset = @mysql_query($query, $connection);
// print MySQL query results as 2D javascript array
function aw_cells($dataset){
$rows = array();
while ($record = @mysql_fetch_row($dataset)) {
$cols = array();
foreach ($record as $value) {
$cols[] = '"'.addslashes($value).'"';
}
$rows[] = "\t[".implode(",", $cols)."]";
}
echo "[\n".implode(",\n",$rows)."\n];\n";
}
// print MySQL field names as javascript array
function aw_headers($dataset){
while ($field = @mysql_fetch_field($dataset)) {
$cols[] = '"'.$field->name.'"';
}
echo "[".implode(",",$cols)."];\n";
}
?>
<html>
<head>
<!-- include AW stylesheet and script -->
<link href="aw.css" rel="stylesheet" type="text/css" ></link>
<script src="aw.js"></script>
</head>
<body>
<script>
// insert javascript arrays produced by PHP functions
var myHeaders = <?= aw_headers($dataset) ?>
var myCells = <?= aw_cells($dataset) ?>
// create grid control
var obj = new AW.UI.Grid;
// set grid text
obj.setHeaderText(myHeaders);
obj.setCellText(myCells);
// set number of columns/rows
obj.setColumnCount(myHeaders.length);
obj.setRowCount(myCells.length);
// write grid to the page
document.write(obj);
</script>
<script>
obj.setCellEditable(true);
obj.onRowAdded = function(row){
window.status = "Row added: " + row;
this.setCellText("new", 0, row);
}
obj.onRowDeleting = function(row){
return !confirm("Delete row " + row + "?");
}
obj.onRowDeleted = function(row){
window.status = "Row deleted: " + row;
}
// row index
var serial = 1000;
function add(){
obj.addRow(serial++);
}
function del(){
var i = obj.getCurrentRow();
obj.deleteRow(i);
}
</script>
<br>
<button onclick="add()">Agrega Registro</button>
<button onclick="del()">Borra Registro</button>
</body>
</html>
<?php
$connection = @mysql_connect('localhost', ' ', ' ');
@mysql_select_db('domini43_clientes', $connection);
$query = 'SELECT * FROM cliente LIMIT 0,10';
$dataset = @mysql_query($query, $connection);
// print MySQL query results as 2D javascript array
function aw_cells($dataset){
$rows = array();
while ($record = @mysql_fetch_row($dataset)) {
$cols = array();
foreach ($record as $value) {
$cols[] = '"'.addslashes($value).'"';
}
$rows[] = "\t[".implode(",", $cols)."]";
}
echo "[\n".implode(",\n",$rows)."\n];\n";
}
// print MySQL field names as javascript array
function aw_headers($dataset){
while ($field = @mysql_fetch_field($dataset)) {
$cols[] = '"'.$field->name.'"';
}
echo "[".implode(",",$cols)."];\n";
}
?>
<html>
<head>
<!-- include AW stylesheet and script -->
<link href="aw.css" rel="stylesheet" type="text/css" ></link>
<script src="aw.js"></script>
</head>
<body>
<script>
// insert javascript arrays produced by PHP functions
var myHeaders = <?= aw_headers($dataset) ?>
var myCells = <?= aw_cells($dataset) ?>
// create grid control
var obj = new AW.UI.Grid;
// set grid text
obj.setHeaderText(myHeaders);
obj.setCellText(myCells);
// set number of columns/rows
obj.setColumnCount(myHeaders.length);
obj.setRowCount(myCells.length);
// write grid to the page
document.write(obj);
</script>
<script>
obj.setCellEditable(true);
obj.onRowAdded = function(row){
window.status = "Row added: " + row;
this.setCellText("new", 0, row);
}
obj.onRowDeleting = function(row){
return !confirm("Delete row " + row + "?");
}
obj.onRowDeleted = function(row){
window.status = "Row deleted: " + row;
}
// row index
var serial = 1000;
function add(){
obj.addRow(serial++);
}
function del(){
var i = obj.getCurrentRow();
obj.deleteRow(i);
}
</script>
<br>
<button onclick="add()">Agrega Registro</button>
<button onclick="del()">Borra Registro</button>
</body>
</html>
Vicente Mexico
July 17,