How to save selected rowid in a php variable and JS

QuestionsHow to save selected rowid in a php variable and JS
Valentine Hundu asked 4 years ago

I tried this but did not work for me.

$id = intval($_GET[“rowid”])

Kindly help

2 Answers
Abu Ghufran Staff answered 4 years ago

Hi,

To get selected row id in JS you can refer this api: https://www.gridphp.com/docs/javascript-api-faqs/

To receive in php, you need some custom ajax call OR trigger insert/update/delete and use callback events to get the posted data.

Check callback event, onSelectRow event usage below:

https://www.gridphp.com/docs/grid-events/

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Valentine Hundu answered 4 years ago

Hi Abu,

 

Thank you for your response.

 

I have tried gone through the link but could not be able to solve my problem.

below is my code,

<?php
include_once(“config.php”);

include(PHPGRID_LIBPATH.”inc/jqgrid_dist.php”);

// Database config file to be passed in phpgrid constructor
$db_conf = array(
“type” => PHPGRID_DBTYPE,
“server” => PHPGRID_DBHOST,
“user” => PHPGRID_DBUSER,
“password” => PHPGRID_DBPASS,
“database” => PHPGRID_DBNAME
);

$col = array();
$col[“title”] = “FullName”; // caption of column, can use HTML tags too
$col[“name”] = “cabinet_name”; // grid column name, same as db field or alias from sql
$col[“width”] = “40”; // width on grid
$col[“editable”] = true;
$cols[] = $col;

$col = array();
$col[“title”] = “Pin”; // caption of column, can use HTML tags too
$col[“name”] = “cabinet”; // grid column name, same as db field or alias from sql
$col[“width”] = “40”; // width on grid
$col[“link”] = “display-pdf.php?cabinet={cabinet}”;
$col[“linkoptions”] = “target=’_self'”;
$col[“editable”] = true;
$cols[] = $col;

$col = array();
$col[“title”] = “Date”; // caption of column, can use HTML tags too
$col[“name”] = “date”; // grid column name, same as db field or alias from sql
$col[“width”] = “40”;
$col[“editable”] = true;
$cols[] = $col;
$g = new jqgrid($db_conf);
$id2 =$_GET[“id”];

$grid[“caption”] = “Sample Grid”;

$g->set_options($grid);
$g->table = “uploaded”;
$id = intval($_GET[“id”]);
$g->set_columns($cols);

$out = $g->render(“list1”);

I want to use the selected ID in the query below

$Orig = $do->gett(“select * from uploaded where id =’$id'”);

if I put the actual rowid it works fine. like

$Orig = $do->gett(“select * from uploaded where id =’123456′”);

 

Kindly help .

Your Answer

3 + 11 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?