pass value from jqgrid to php and dispaly the data based on the value passed

Carino

i have the below two php files and i trying to pass the value from the selected option to the base php file and display the information based on the passed file.

fkm_test.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8″ />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>APP FKMS</title>

<link rel="stylesheet" type="text/css" media="screen" href="../js/jquery-ui-1.10.3.custom_blackGreen/jquery-ui-1.10.3.custom/css/trontastic/jquery-ui-1.10.3.custom.min.css" />
<link rel="stylesheet" type="text/css" media="screen" href="../js/jquery.jqGrid-4.5.2/css/ui.jqgrid.css" />


<script src="../js/jquery-ui-1.10.0.custom/jquery-1.9.0.min.js" type="text/javascript"></script>
<script src="../js/jquery.jqGrid-4.5.2/js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="../js/jquery.jqGrid-4.5.2/js/jquery.jqGrid.min.js" type="text/javascript"></script>

<script type="text/javascript">
function fkm(Application) {
var app = document.getElementById("myApp").selectedIndex;
var app_selected = document.getElementsByTagName("option")[app].value;
alert (app_selected);
//alert(document.getElementsByTagName("option")[app].value);
var lastSel
$("#list").jqGrid({

    url: "fkm_display.php?app=$app_selected",
    editurl: "fkmedit.php",
    datatype: "json",
    mtype: "GET",
    colNames: ["App", "Pattern Type", "Pattern", "Rank", "AMRS", "EMEA", "APAC", "Audit", "ID", "Alert Type", "Comments"],
    colModel: [
        { name: "division", width: 75 , editable: true},
        { name: "pattern_type", width: 90, editable: true, edittype:"select",formatter:'select', editoptions:{value:"BASIC:BASIC;REGEXP:REGEXP;REGEXP_IGNORE_CASE:REGEXP_IGNORE_CASE" } },
        { name: "pattern", width: 650, editable: true },
        { name: "rank", width: 50 },
        { name: "amrs_active", width: 40, editable: true, edittype:"select",formatter:'select', editoptions:{value:"1:Active;0: " } },
        { name: "emea_active", width: 40, editable: true, edittype:"select",formatter:'select', editoptions:{value:"1:Active;0: " } },
        { name: "apac_active", width: 40, editable: true, edittype:"select",formatter:'select', editoptions:{value:"1:Active;0: " } },
        { name: "audit", width: 200},
        { name: "id", width: 10, hidden: true},
        { name: "type", width: 20, editable: true, edittype:"select", sorttype:"text",formatter:'select', editoptions:{value:"IGNORE:IGNORE;ALERT:ALERT;WARN:WARN" } },
        { name: "comments", width: 10, editable: true,hidden: true}
    ],
    height: 'auto',
    pager: "#pager",
    rowNum: 90,
    rowList: [10, 20, 30, 60, 90],
    sortname: "rank",
    sortorder: "asc",
    viewrecords: false,
    gridview: true,
    autoencode: true,
    toppager: true,
    grouping:true,
    groupingView : {
            groupField : ['type'],
            groupColumnShow : [true],
            groupText : ['<b>{0} - {1} Item(s)</b>']
    },
    caption: "Application FKMs"
});
jQuery("#list").jqGrid('filterToolbar', { stringResult: true, searchOnEnter: false, defaultSearch: 'cn', ignoreCase: true});
jQuery("#list").jqGrid('navGrid','#pager',{"add":true,"del":true, "edit":true,"search":false,"refresh":true,"view":false, "cloneToTop":true});
};
</script>

</head>
<body>
<form id="phpform" name="phpform" method="POST" action="javascript:fkm();">
<select name="Application" id="myApp" >
<option selected="selected">–Select Application–</option>
<?php
include ('app_dbconfig.php');
$sql = "SELECT * FROM applications order by Application asc";
$result = mysql_query($sql) or die("SQL Error 1: " . mysql_error());

while($row=mysql_fetch_assoc($result))
{
echo '<option value="' . $row['Application'] . '">' . $row['Application'] . '</option>';
}
?>
</select>
<input type="submit" name="testing" value="Submit" >
</form>
<div align="center">
<table id="list"><tr><td></td></tr></table></div>
<div id="pager"></div>
</body>
</html>

fkm_display.php

<?php 
include("fkm_dbconfig.php");

$page = $_GET['page'];
$limit = $_GET['rows']; 
$sidx = $_GET['sidx']; 
$sord = $_GET['sord']; 

$app = $_GET['app_selected'];


if(!$sidx) $sidx =1; 
$result = mysql_query("SELECT COUNT(*) AS count FROM global_itrs_fkms");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
$total_pages=0;
if( $count >0 ) {
    $total_pages = ceil($count/$limit);
} else {
    $total_pages = 0;
}
if ($page > $total_pages) $page=$total_pages;
$start = $limit*$page - $limit; 

$filterResultsJSON = json_decode($_REQUEST['filters']);


if($filterResultsJSON){
$filterArray = get_object_vars($filterResultsJSON);


$filterResultsJSON = json_decode($_REQUEST['filters']);

$filterArray = get_object_vars($filterResultsJSON);}
$SQL = "select division,pattern_type,pattern,rank,amrs_active,emea_active,apac_active,concat(audit,' ', timestamp) as audit,id,type from global_itrs_fkms";


$counter = 0;
while($counter < count($filterArray['rules']))
{
$filterRules = get_object_vars($filterArray['rules'][$counter]);

if($counter == 0){
$SQL .= ' WHERE ' . division = '$app' . $filterRules['field'] . ' LIKE "%' . $filterRules['data'] . '%"';
}

else {
$SQL .= ' AND ' . $filterRules['field'] . ' LIKE "%' . $filterRules['data'] . '%"';
}
$counter++;
}

$SQL .= " order by $sidx $sord LIMIT $start, $limit";
echo $SQL;

$result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error());

$responce['total'] = $total_pages;
$responce['page'] = $page;
$responce['records'] = $count;
$i=0;
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
$responce['rows'][$i]['id']=$row[id];
$responce['rows'][$i]['cell']=array($row[division],$row[pattern_type],$row[pattern],$row[rank],$row[amrs_active],$row[emea_active],$row[apac_active],$row[audit],$row[id],$row[type]);
$i++;
}        
echo json_encode($responce);

If i change the url: "fkm_display.php?app=$app_selected" to url: "fkm_display.php" and when i click on submit am getting the enitre db information, which i don't want. I need only the information related to the application selected.

Vinoth Krishnan

I am not sure, what is your actual problem. May be your jQgrid URL has not correctly formatted. You need to change like this,

url: "fkm_display.php?app="+app_selected,

Since your app_selected is a javascript variable not php variable. And in your server side you need to get the value like this,

$app = $_GET['app'];

But you are using like $app = $_GET['app_selected']; in your php code. Because you are setting the value of app_selected to app variable in your jQgrid code. Hope this helps.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Pass value from php to javascript

From Dev

Pass value from php to javascript

From Dev

Pass value from php to Jscript

From Dev

Echo data retrieved from query to a table PHP based on same value

From Dev

How to remove extra column value from jqgrid json data

From Dev

JQGrid: Pass JQGrid column value as a parameter to controller method specified in cellurl

From Dev

jqGrid rowformatter based on separate cells value

From Dev

How to pass value from database to popup in php?

From Dev

Pass value from php form to Paypal amount

From Dev

Pass value from PHP to JS with Smarty?

From Dev

Pass value from php form to Paypal amount

From Dev

How to pass value from json to php

From Dev

How to pass value from database to popup in php?

From Java

How to pass a value from Vue data to href?

From Dev

How to dispaly selected value in edit page

From Dev

seperate each array value from array passed by ajax -- php

From Dev

PHP cookie value not being passed from one page to another

From Dev

Value in Android not being passed to PHP

From Dev

Value in Android not being passed to PHP

From Dev

Pass pointer by value where it is supposed to be passed by reference

From Dev

get text from jqgrid cell value

From Dev

Function to return colour based on value passed

From Java

Get consecutive values based on value being passed in

From Dev

Change class property value based on passed parameter

From Dev

Function to return colour based on value passed

From Dev

Passed array to php from jquery with ajax value just shows Array not actual array value

From Dev

pass value to attribute based on received value

From Dev

php array value from data tag to jQuery

From Dev

calculate value based on value from previous value

Related Related

  1. 1

    Pass value from php to javascript

  2. 2

    Pass value from php to javascript

  3. 3

    Pass value from php to Jscript

  4. 4

    Echo data retrieved from query to a table PHP based on same value

  5. 5

    How to remove extra column value from jqgrid json data

  6. 6

    JQGrid: Pass JQGrid column value as a parameter to controller method specified in cellurl

  7. 7

    jqGrid rowformatter based on separate cells value

  8. 8

    How to pass value from database to popup in php?

  9. 9

    Pass value from php form to Paypal amount

  10. 10

    Pass value from PHP to JS with Smarty?

  11. 11

    Pass value from php form to Paypal amount

  12. 12

    How to pass value from json to php

  13. 13

    How to pass value from database to popup in php?

  14. 14

    How to pass a value from Vue data to href?

  15. 15

    How to dispaly selected value in edit page

  16. 16

    seperate each array value from array passed by ajax -- php

  17. 17

    PHP cookie value not being passed from one page to another

  18. 18

    Value in Android not being passed to PHP

  19. 19

    Value in Android not being passed to PHP

  20. 20

    Pass pointer by value where it is supposed to be passed by reference

  21. 21

    get text from jqgrid cell value

  22. 22

    Function to return colour based on value passed

  23. 23

    Get consecutive values based on value being passed in

  24. 24

    Change class property value based on passed parameter

  25. 25

    Function to return colour based on value passed

  26. 26

    Passed array to php from jquery with ajax value just shows Array not actual array value

  27. 27

    pass value to attribute based on received value

  28. 28

    php array value from data tag to jQuery

  29. 29

    calculate value based on value from previous value

HotTag

Archive