Hi,
My DB field that contains the name of uploaded file is doc_file.
I need to get the extension of the file and tried this:
$ext = substr($row['doc_file'],-3);
and also …
$ext = substr($data['doc_file'],-3);
neither of them works … How can I do that ??
Thanks,
… I also tried this
$col["condition"] = array('substr({doc_file},-3) == "pdf"', $icone = "doc_pdf.png", $icone = "doc_office.png");
It doesn't work ! … can I use a php (substr) inside a condition ?
Thanks,
Pasting from docs:
For extended conditional data, you can also have callback function, that will allow you to display based on row data. For e.g.
$col["on_data_display"] = array("display_keyword","");
function display_keyword($data)
{
$kw = $data["keyword_name"];
$numKeywords = count(explode("n",$pass));
if ($numKeywords > 3)
return $numKeywords." Keywords";
else
{
$pass = str_replace("+"," ",$pass);
return $pass;
}
}
Hi,
I've already read this but didn't understand how it solve my problem … not clear for me.
Sorry,
Not tested the code, but it would be something like:
$col["on_data_display"] = array("display_icon","");
function display_icon($data)
{
$file = $data["doc_file"];
if (substr($file,-3) == "pdf")
return "doc_pdf.png";
else
return "doc_office.png";
// it can also be: return "<img src='doc_office.png'>";
}