我正在尝试创建一个翻译工具,一次插入多个翻译 ..我创建了这个MySQL查询..但它不起作用:(
基本上,我从表<tr>
中获取英语值,并为此表中的每条记录创建一个mode=translate
表元素。
表单就在此处,translated2
下的翻译应插入 if($_GET['mode'] && $_GET['mode'] == "translate") {
if ( !empty($_POST['variable']) && !empty($_POST['content']) && is_array($_POST['variable']) && is_array($_POST['content']) && count($_POST['variable']) === count($_POST['content']) ) {
$variable_array = $_POST['variable'];
$content_array = $_POST['content'];
$page_array = $_POST['page'];
$mylang = $user['uboard'];
$editor = $user['uid'];
$proj = $_GET['project'];
for ($i = 0; $i < count($variable_array); $i++) {
$variable = mysql_real_escape_string($variable_array[$i]);
$content = mysql_real_escape_string($content_array[$i]);
$page = mysql_real_escape_string($page_array[$i]);
mysql_query("INSERT INTO `translated2` (id, variable, content, lang, sender, editor, page, new, array, when, project) VALUES (NULL, '$variable', '$content', '$mylang', '$sender', '$editor', '$page', '2', '0', NULL, '$proj')")
or die("primo".mysql_error());
mysql_query("UPDATE `translations2` SET `$mylang` = '1' WHERE `variable` = '$variable';")
or die("secondo".mysql_error());
}
}
}
。
<form method="post" action="../langues/index.php?view=lang&project=<?php echo $proj; ?>&mode=translate"> <table class="table table-hover">
<tbody>
<tr><th class="clickable" style="width:15%;font-weight: bold; position: relative; padding-bottom: 20px; padding-top: 5px; text-transform: uppercase; font-size: 11px; vertical-align: top;"> Alias </th>
<th class="thlisting" style="width:15%;font-weight: bold; position: relative; padding-bottom: 20px; padding-top: 5px; text-transform: uppercase; font-size: 11px; vertical-align: top;"> English value </th>
<th class="thlisting" style="width:15%;font-weight: bold; position: relative; padding-bottom: 20px; padding-top: 5px; text-transform: uppercase; font-size: 11px; vertical-align: top;"> Translation </th>
<th class="thlisting" style="width:15%;font-weight: bold; position: relative; padding-bottom: 20px; padding-top: 5px; text-transform: uppercase; font-size: 11px; vertical-align: top;"> Page </th>
</tr>
<?php
$result_select = mysql_query($query_select) or die(mysql_error());
$rows = array();
while($row = mysql_fetch_array($result_select))
$rows[] = $row;
foreach($rows as $row){
$variable = stripslashes($row['variable']);
$content = stripslashes($row['content']);
$project = stripslashes($row['project']);
$page = stripslashes($row['page']);
?>
<tr class="<?php echo $variable; ?>">
<td style="word-break:break-all; width:15%">
<input type="hidden" name="variable" value="<?php echo $variable; ?>">
<input type="hidden" name="project" style="font-size: 12px;" value="<?php echo $project; ?>">
<?php echo $variable; ?>
</td>
<td style="width:35%; font-size: 12px;" >
<?php echo $content; ?>
</td>
<td style="width:35%">
<textarea name="content" rows="6" cols="40" class="input-xlarge"><?php echo $content; ?></textarea>
</td>
<td style="width:15%">
<input type="text" name="<?php echo $page; ?>" value="page">
</td>
</tr>
<?php
}
?>
<tr>
<td colspan="4" style="height:50px; text-align:right;">
<input type="submit" value="Save" class="btn-flat default pull-right">
</td>
</tr>
</tbody></table></form>
这是PHP代码:
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
任何人都可以帮我解决这个问题吗?