Hello,
Thank you four you job.
I have tried to find an answer on my question but didn't found.
I'm not experienced with PHP and not sure if this question is regarding PHP Grid.
Could you please assist me with the following:
For example I have
$data["params"]["ID"]
1
2
3
$data["params"]["Name"]
John
Sara
Jerry
$data["params"]["Title"]
Manager
Sales
Sales
It there a way how to get ID, Name, Title as ID, Name, Title not as value (1,2,3,4; John,Sara,Jerry; Manager,Sales,Sales etc) when I'm doing foreach with it?
function update_client($data)
{
foreach($data[params] as $d)
{
echo 'Something here to get ID as row name in $data["params"]["ID"]["Name"]["Title"]';
echo $d;
\'echo' is just example to simplify the code. There will be mysql insert queries.
}
}
I would like to get output like bellow:
ID
1
Name
John
Title
Manager
Thank you.
If i understand your query correctly, you can explode the data with comma and run insert or update query inside loop.
e.g. http://pastebin.com/5N2kz072
If there is something different, please share screenshot/code.
Hi,
Thank you for helping, but seems like there is something different.
Code is below:
function update_client($data)
{
foreach($data[params] as $d)
{
$LogTable = "`activity_log`";
global $StringID;
global $user;
mysql_query("INSERT INTO $LogTable (`action`,`attribute_name`,`new_value`, `updated_by`) VALUES ('Update', '$data[params][COLUMN_NAME not its Value]','$d', '$user')");
}
}
What I would like to get in Mysql after insert:
Select * from `activity_log`
Action Attribute_Name new_value updated_by
Update ID 1 John Dow
Update Name John John Dow
Update Title Manager John Dow
Update ID 2 John Dow
Update Name John John Dow
Update Title Sales John Dow
Update ID 3 Sara Jones
Update Name Sara Sara Jones
Update Title Sales Sara Jones
You can use foreach with key => value format like …
foreach($data[params] as $k=>$d) { } and use $k as field name.
…..
function update_client($data)
{
foreach($data[params] as $k=>$d)
{
$LogTable = "`activity_log`";
global $StringID;
global $user;
mysql_query("INSERT INTO $LogTable (`action`,`attribute_name`,`new_value`, `updated_by`) VALUES ('Update', '$k','$d', '$user')");
}
}