PHP CONNECTOR CONFUSION WITH BEFORERENDER

Good afternoon all,
I have a question that I’m hoping someone can some can help me on. I have been looking at PHP connector reference and PHP connector formatting to understand how to insert an image using beforeRender.


<?php

require_once("../_dhtmlx/grid_server/codebase/connector/grid_connector.php");
require_once("../_dhtmlx/grid_server/codebase/connector/form_connector.php");
require_once("../_dhtmlx/grid_server/codebase/connector/db_mysqli.php");

$server = "";
$user = "";
$pass = "";
$mysql_db = "";

$mysqli = new mysqli($server, $user, $pass, $mysql_db); 
$gridConn = new GridConnector($mysqli,"MySQLi");
$formConn = new FormConnector($mysqli,"MySQLi");

//this is my test to see if it grabs the data and insert it into test
function formatting($data){
    //save in userdata 
    $data->set_userdata("test",$row->get_value("gradelevel"));
}

$type = $_GET["type"];
if($type=="grid") {
    //$gridConn->event->attach("beforeRender","formatting");
    $gridConn->render_table("reported","id","gradelevel, playername,report_date","test"); 
} else if($type=="form") {
    $formConn->render_table("reported","id","playername,report_date,reason,nexon_report,evidence_a,evidence_b,evidence_c,evidence_d,evidence_e,evidence_f,username");
}
 

“test” is going to be where the image goes for a delete image. But the event is a test to see if it outputs to a field that doesn’t exist.
So how do I insert another column that doesn’t exist and place an image in there. Let me know if you need any more clarification.

Never mind I figured it out.

I had to create two additional fields in my database that are always gonna be empty “edit” and “delete”.
then I had to use “beforeRender” to set the value of those two fields.

Also guys, if you want to include an image with before render, make sure you either have something in the database to identify the image: ex smiley.gif

Then in beforeRender, just put the complete link without <img in it.


function your_function($data) {
    $icon= $data->get_value("column name"); // smiley.gif will be pulled from db
    $img = "http://link to image".$icon";
    $data->set_value("row name",$img);
}

also, make sure you set the setColTypes to img. I don’t know how to add a fake column name so you don’t have to add a column name to the database. If someone does know, please add onto this.