<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Web management</title>
<link rel="stylesheet" href="styles.css" type="text/css">
<?php include 'codes.php';?>
</head>
<body>
<?php 
$insertid = mysql_real_escape_string(stripslashes($_REQUEST['id']));
$name = mysql_real_escape_string(stripslashes($_REQUEST['name']));
?>

<table width="980" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><div><img src="img/frame-edit.png" width="180" height="37" alt=""></div>
<div class="frame">
<?php
$result = mysql_query("SELECT * FROM langtexts WHERE insert_id='$insertid' AND lang_id=1",$dbh);
$myrow=mysql_fetch_array($result); 
$name=$myrow['name'];
?>
<form name="forma" method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $insertid ?>">

<table width="100%" border="0" cellspacing="0" cellpadding="3">
    <tr>
      <td width="20">&nbsp;</td>
      <td width="200">Τίτλος</td>
      <td>
     <input type="text" name="name" value="<?php echo $name ?>" size="100" class="forms"> 
      </td>
    </tr>
    </table>
    
<?php
$sql50 = "SELECT * FROM lang WHERE active=1 ORDER BY id";
$result50 = mysql_query($sql50);
while ($myrow=mysql_fetch_array($result50)) {
$langid=$myrow['id'];
$language=$myrow['language'];
$dir=$myrow['dir'];
?>

<?php
$sql51 = "SELECT * FROM langtexts WHERE insert_id='$insertid' AND lang_id='$langid'";
$result51 = mysql_query($sql51);
while ($myrow=mysql_fetch_array($result51)) {
$name=$myrow['name'];
$insert_id=$myrow['insert_id'];
$lang_id=$myrow['lang_id'];
$name=$myrow['name'];
$text=$myrow['text'];
?>

<?php 
if  (isset($_POST['submit'])) {
$name = mysql_real_escape_string(stripslashes($_REQUEST['name']));
$text = mysql_real_escape_string(stripslashes($_REQUEST["text$langid"]));
$textlang = mysql_real_escape_string(stripslashes($_REQUEST["text$langid"]));

$sql="UPDATE langtexts SET name='$name', text='$textlang' WHERE insert_id='$insertid' AND lang_id='$langid'";
$result = mysql_query($sql);

} ?>

  <table width="100%" border="0" cellspacing="0" cellpadding="4">
    <tr>
      <td width="20"><img src="img/<?php echo $dir ?>.png" width="16" height="16" alt=""></td>
      <td width="200">Κείμενο </td>
      <td><textarea name="text<?php echo $langid ?>" cols="100" rows="3" class="forms"><?php echo $text ?></textarea></td>
    </tr>
    </table>

<?php } ?>
<?php } ?>

<!--NEW LANG -->

<?php
$sql52 = "SELECT * FROM lang WHERE id NOT IN (SELECT lang_id FROM langtexts WHERE insert_id='$insertid') AND active=1 ORDER BY id";
$result52 = mysql_query($sql52);
$nu_row52 = mysql_num_rows($result52);
while ($myrow=mysql_fetch_array($result52)) {
$langid2=$myrow['id'];
$language2=$myrow['language'];
$dir2=$myrow['dir'];
?>

<?php if  ($nu_row52>0) { ?>

  <table width="100%" border="0" cellspacing="0" cellpadding="4">
    <tr>
      <td width="20"><img src="img/<?php echo $dir2 ?>.png" width="16" height="16" alt=""></td>
      <td width="200">Κείμενο </td>
      <td><textarea name="text<?php echo $langid2 ?>" cols="100" rows="3" class="forms"></textarea></td>
    </tr>
    </table>
    
<?php 
if  (isset($_POST['submit'])) {
$textlang2 = mysql_real_escape_string(stripslashes($_REQUEST["text$langid2"]));

$sql = "INSERT INTO langtexts (insert_id, lang_id, name, text) VALUES ('$insert_id', '$langid2', '$name', '$textlang2')";
$result = mysql_query($sql);
?>

<meta http-equiv="refresh" content="0;URL=edit-langtext.php?id=<?php echo $insertid ?>">    
    
<?php } ?>
<?php } ?>
<?php } ?>

<!--END NEW LANG -->

<div align="center" style="padding:5px">
  <input type="submit" name="submit" value="Καταχώρηση" class="button">
   <input type="reset" name="reset" value="Επαναφορά" class="button">  
 </div>
   
</form>  

</div>
<div align="right"><a href="all-langtexts.php" class="links">μεταφορά στην Λίστα</a></div></td>
  </tr>
</table>
<?php include 'menudown.php';?>

</body>
</html>
