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

Can someone help me, please?

Member Avatar for diafol

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?

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

Member Avatar for diafol

So the while?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.