php postgresql concat hyperlink with fields

966 Views Asked by At

How to concat hyperlink in php postgresql query? I tried this but confused with single and double quotes.

$query = "SELECT im.id AS \"ID\",
          im.type AS \"TYPE\",
         CONCAT('<a href=\"\" onclick=(\"'".im.id."'\)">Click</a>')
FROM instancemaster im
WHERE imd = "."'$imd'";

My problem is the CONCAT part getting syntax error.

I tried like this, as I have innerjoin as well where 'im.id' table alias is conflicting with php concatenation.

CONCAT('<a onclick=\"', ".im.id.", '\">', Click, '</a>')
1

There are 1 best solutions below

0
On BEST ANSWER

Concat like glues text together. I don't see any comas in your CONCAT, try

CONCAT('<a href=\"\" onclick=(\"' , im.id , '\")>Click</a>') 

and if your imd is just an integer then you can use

WHERE imd =$imd;