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

<!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 = mysql_query("SELECT * FROM `content_empresa`") or die(mysql_error());
while($row = mysql_fetch_array($sentence)){
?>
<div class="etiquetas">
<div class="tit_etiq">
<?
$titulo= $row;
$id= $row;
$descricao = $row;
$imagem= $row;
echo"$id";
echo"$titulo";
?>
</div>
<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>
</div>
<?
}
?>


<div class="display">
<form>
<textarea class="area_visualza" disabled="disabled">
<? echo"$descricao"; ?>
</textarea>
</form>


</div>
<div class="update">
<form action="POST">
<textarea class="area_visualza" >
<?
echo "$descricao";
?>
</textarea>
<input type="submit" action="POST"><input>
</form>
</div>
</div>
</div>


</div>
<body>
</body>
</html>

Hope that helped I cleared up as much as possible, I am not familiar with your language and so I'm not too sure but yeah good luck and if you need more help try another thread or re-post here :)
Also if this solves your issue then simply "mark as solved" this thread.

Sorry for the language used in the page (Portuguese) if it confused you up a bit. However I quited using this aproach, and started using a CRUD like aproach, redirecting each click to its respective action. I couldn't loose to much time figuring out what was going wrong with this. Maybe in a few days I'll be updating this to be more visually atractive.

Anyway, although I've tested it with no success, thank you very much for you patience and help! ;)

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.