0

Hi,

i'm editing results, but i want that all info of the result i select appears in the respective textbox's, waht happens to me is that everything is blank even the first combo box:

admin.php

<td width="5%">
         <a href="edit.php?id=<?php echo $row_cont_lang['id']; ?>">Editar</a>
      </td>

edit.php

<?PHP
include 'db_connect.php';
session_start();
if (isset($_GET['id']))
{
$sel_id = "SELECT * FROM content_lang WHERE id='".$_GET['id']."'";
$ident = mysql_query($sel_id, $connect);
$row_id = mysql_fetch_assoc($ident);
?>
<html>
<head>
   <title>Administração - Editar</title>
</head>
<body style="color:#FFFFFF;" bgcolor="#666666">
<form action="" method="post">
   <table >
    <tr>
   <td align="right">
    Identificador:
   </td>

   <td>
    <select name="identifier">

     <?php
     do{
     $select_content_lang = "SELECT * FROM content_lang WHERE id='".$row_id['id_content']."'";
     $content_lang = mysql_query($select_content_lang, $connect);
     $row_content_lang = mysql_fetch_assoc($content_lang);

     $sel_cont="SELECT * FROM content WHERE id_content='".$row_content_lang['id_content']."'";
     $cont=mysql_query($sel_cont, $connect);
     $row_cont=mysql_fetch_assoc($cont);
     ?>

      <option value="<?php echo $row_cont['id_content']; ?>">
     <?PHP echo $row_cont['identifier']; ?>
      </option>

    <?PHP
    } while ($row_id = mysql_fetch_assoc($ident));
    ?>
    </select>
   </td>
    </tr>

    <tr height="10px"></tr>

    <tr>
   <td align="right">
    Linguagem:
   </td>

   <td>
    <select name="lang">

    <option value="pt">
      Português
     </option>

     <option value="en">
      Inglês
     </option>

    </select>
   </td>
    </tr>

    <tr height="10px"></tr>

    <tr>
   <td align="right">
    Título:
   </td>

   <td>
    <input value="<?php echo $row_content_lang['titulo']; ?>" type="text" name="titulo">
    </input>
   </td>
    </tr>

    <tr height="10px"></tr>

    <tr>
   <td align="right" valign="top">
    Conteúdo:
   </td>

   <td>
    <textarea name="descricao" cols="50" rows="10"><?php echo $row_content_lang['descricao']; ?></textarea>
   </td>
    </tr>

    <tr>
   <td></td>

   <td>
    <input type="submit" name="update" value="Editar Informação" />
    <a href="admin.php"><input type="button" name="update" value="Voltar"/></a>
   </td>
    </tr>
   </table>
</form>
</body>
</html>
<?php
if (isset($_POST['update']))
{
   $identifier=$_POST['identifier'];
   $lang=$_POST['lang'];
   $titulo=$_POST['titulo'];
   $descricao=$_POST['descricao'];
   $update_info="UPDATE content_lang
    SET id_content='".$identifier."', lang='".$lang."', titulo='".$titulo."', descricao='".$descricao."'
    WHERE id='".$row_id['id']."'";
   $info=mysql_query($update_info, $connect);

   if (!$info)
   {
  echo '<script>alert("Erro na edição devido a um erro no sistem. Tente mais tarde");
   location.href="admin.php"<script>';
   }
   else
   {
  echo '<script>alert("Informação editada com sucesso.");
   location.href="admin.php";</script>';
   }
}
}
?>

Can someone help me, please? it's urgent

Thank you,
PF2G

2
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by diafol
0

First of all, check to see if you get a record:

$sel_id = "SELECT * FROM content_lang WHERE id='".$_GET['id']."'";
$ident = mysql_query($sel_id, $connect);
echo "No. records = " . mysql_num_rows($ident) . "<br />";
$row_id = mysql_fetch_assoc($ident);

WHy are you doing a do/while why not just a while{} ?

Your language bits may be better served in an array in a language file as opposed to being stored in a DB?

0

It gives me the correct number of total records...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.