Php INNER JOING jqGrid help
Posted
by
yanike
on Stack Overflow
See other posts from Stack Overflow
or by yanike
Published on 2010-12-27T20:21:25Z
Indexed on
2010/12/27
20:54 UTC
Read the original article
Hit count: 293
I'm trying to get INNER JOIN
to work with JQGRID
, but I can't get it working. I want the code to get the first_name and last_name from members using the "efrom" from messages that matches the "id" from members.
$col = array();
$col["title"] = "From";
$col["name"] = "messages.efrom";
$col["width"] = "70";
$col["hidden"] = false;
$col["editable"] = false;
$col["sortable"] = true;
$col["search"] = true;
$cols[] = $col;
$col = array();
$col["title"] = "First Name";
$col["name"] = "members.first_name";
$col["width"] = "80";
$col["hidden"] = false;
$col["editable"] = false;
$col["sortable"] = true;
$col["search"] = true;
$cols[] = $col;
$col = array();
$col["title"] = "Last Name";
$col["name"] = "members.last_name";
$col["width"] = "80";
$col["hidden"] = false;
$col["editable"] = false;
$col["sortable"] = true;
$col["search"] = true;
$cols[] = $col;
$col = array();
$col["title"] = "Subject";
$col["name"] = "messages.esubject";
$col["width"] = "300";
$col["hidden"] = false;
$col["editable"] = false;
$col["sortable"] = true;
$col["search"] = true;
$cols[] = $col;
$col = array();
$col["title"] = "Date";
$col["name"] = "messages.edatetime";
$col["width"] = "150";
$col["hidden"] = false;
$col["editable"] = false;
$col["sortable"] = true;
$col["search"] = true;
$cols[] = $col;
$g = new jqgrid();
$grid["sortname"] = 'messages.edatetime';
$g->select_command = "SELECT messages.efrom, messages.esubject, messages.edatetime, members.first_name, members.last_name FROM messages INNER JOIN members ON messages.efrom = members.id";
© Stack Overflow or respective owner