Hi There
I've been hammering my head with this for quite a while, and every solution I've tried didn't work, so I was wandering if you could help me with this.
I've got a small div that is displayed for each record existing in the database, in order that, later, users are able to "apply some CRUD" to the records.
However, the code that I have written (in javascript) to show or hide the div's that display or update the fields (haven't written the one to delete yet), are just displaying the records for one field, either if I click the button to edit another field or not, it just displays the same record.
Is there any way, that, given an unique ID stored in the database, this starts working properly?
Here's the code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt-pt">
<?php include '../includes/bdconn.php'?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link href="../css/style_back.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/jquery-1.4.4.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// Hide the "view" div.
$('div.display').hide();
// Watch for clicks on the "slide" link.
$('div.visualiza').click(function() {
// When clicked, toggle the "view" div.
$('div.display').slideToggle(400);
return false;
});
});
$(document).ready(function() {
// Hide the "view" div.
$('div.update').hide();
// Watch for clicks on the "slide" link.
$('div.edita').click(function() {
// When clicked, toggle the "view" div.
$('div.update').slideToggle(400);
return false;
});
});
</script>
<title>Untitled Document</title>
</head>
<div id="container_back">
<div id="container_menu">
<div class="menu_bar">
<ul>
<a href="../backoffice.php" class="home"><li></li></a>
<a href="back_empresa.php" class="company"><li></li></a>
<ul>
</div>
</div>
<div id="contentor_modulos">
<div class="contentor_titulo">
<div class="titulo_modulo">TITULO DO MÓDULO</div>
</div>
<div class="contentor_records">
<?php
$sentence = "SELECT ID,titulo,descricao,imagem FROM content_empresa";
$query = mysql_query($sentence);
if(!$query)
{
echo "Erro ao executar a query".mysql_error();
}
while ($row = mysql_fetch_array($query)){
echo'<div class="etiquetas">';
echo '<div class="tit_etiq">';
$titulo=$row['titulo'];
$id=$row['ID'];
$descricao = $row['descricao'];
$imagem=$row['imagem'];
echo $id;
echo $titulo;
echo'</div>';
echo'<div class="botoes_comando">
<a href="#"><div class="visualiza"></div></a>
<a href="#"><div class="edita"></div></a>
<a href="#"><div class="elimina"></div></a>
</div>';
echo'</div>';
}
echo' <div class="display">
<form>
<textarea class="area_visualza" disabled="disabled">';
echo $descricao;
echo'</textarea>
</form>
</div>
<div class="update">
<form action="POST">
<textarea class="area_visualza" >';
echo $descricao;
echo'</textarea>
<input type="button" action="POST"><input>
</form>
</div>
</div>';
?>
</div>
</div>
<body>
</body>
</html>
Thanks in advance