Php INNER JOING jqGrid help
- by yanike
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";