Hi. Below is the code which parse data from mysql into json, but for the name column i want to have <a href="http://example.com">column name</a> instead of jst the column 'name'. is it possible in any ways.

<?php
$link = mysql_pconnect("localhost", "user", "pass") or die("Could not connect");
mysql_select_db("userdb") or die("Could not select database");

$arr = array();

$rs = mysql_query("SELECT id, name, active, date FROM clicks");

while($obj = mysql_fetch_object($rs)) {
$arr[] = $obj;
}
echo ''.json_encode($arr).';';
/*
//The json object is :
*/
?>

Thanks

Member Avatar for diafol

For:

"SELECT id, name, active, date FROM clicks"

Use:

"SELECT `id`, `name`, `active`, `date` FROM `clicks`"

date is a reserved word in mysql

For:

mysql_* functions

Use:

PDO/mysqli

It should work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.