I am adding multiple languages to my custom CMS. I'm trying to have multiple language titles of the articles, based on the POSTed Language ID [language_id]
. The $title_[$lid]
should SET into DB's field a_title_[$lid]
. I don't think I'm using a_title_[$lid]
correctly. I would be immensely appreciative for any prompt help. I'm stuck in the water and under the gun.
$aid = trim(cleanQuery($_POST[article_id]));
$lid = trim(cleanQuery($_POST[language_id]));
$title_[$lid] = trim(cleanQuery($_POST[title_][$lid]));
mysql_query("UPDATE articles SET a_title_[$lid] ='$title_[$lid]' WHERE aid='$aid'");
I'm assuming that you don't want to use arrays but dynamic variables names. So if you want to have variables $title_1, $title_2, $title_3. You need to use {}
like that:
${'title_' . $lid} = trim(cleanQuery($_POST['title_'][$lid])); // or maybe trim(cleanQuery($_POST['title_' . $lid]));
And your query should look like this:
mysql_query("UPDATE articles SET a_title_$lid ='${'title_' . $lid}' WHERE aid='$aid'");