I there everyone.
I've been wondering if someone could help to glue up my broken head with this one.
I've got some "labels" which show up, dynamicaly, the data coming from mySql through PHP. In those labels I've got 4 buttons for uploading an image, deleting the respective entry, editing and view the entry with its respective ID.
However, i've trying with jQuery to add some "on the fly" features, in other words, for example, if I click in "view" button, it would only show that specific ID data without going to another page (that would be to easy :D), but by showing an hidden DIV with that content.
But it has some flaws, because, if I click that button, it shows all the divs to all the records which I don't want.
Here's the jQuery code:
$(document).ready(function() {
// hides the slickbox as soon as the DOM is ready
$('div.contentor_visualiza').hide();
// shows the slickbox on clicking the noted link
// toggles the slickbox on clicking the noted link
$('div.visualiza').click(function() {
$('div.contentor_visualiza').toggle(200);
return false;
});
});
AND THE HTML CODE
<div class="contentor_records">
<?php
$sentence = "SELECT ID,titulo,descricao,imagem FROM $table ";
$query = mysql_query($sentence);
if(!$query)
{
echo "Erro ao executar a query".mysql_error();
}
while ($row = mysql_fetch_array($query)){
$titulo=$row['titulo'];
$id=$row['ID'];
$descricao = $row['descricao'];
$imagem=$row['imagem'];
echo'<div class="etiquetas">';
echo '<div class="tit_etiq">';
echo $titulo;
echo'</div>';
echo'<div class="botoes_comando">
<a href="#"><div class="visualiza" id="visualiza"></div></a>
<a href="view.php?id='.$id.'"><div class="edita"></div></a>
<a href="../crud/delete.php?id='.$id.'&mod='.$table.'"><div class="elimina" id="delete"></div></a>
<a href="../upload/upload_crop.php?id='.$id.'&mod='.$table.'"><div class="up_imagem"></div></a>
</div>';
echo'</div>
<div class="contentor_visualiza" id="contentor_visualiza'.$id.'">
<?php $table = "content_empresa";?>
<div class="insert">
<form name="edita_records" method="POST" action="../crud/insert.php?mod=<?php echo $table ?>">
<textarea class="area_titulo_adic" name="titulo_emp">';
echo $titulo;
echo'</textarea>
<textarea class="area_visualiza" name="content_emp">';
echo $descricao;
echo '</textarea>
<div class="buttons">
<input type="submit" name="inserir" class="positive" value="Guardar">
<img src="../gfx/guardar.png" alt=""/>
</input>
</div>
</form>
</div>
</div>';
}
echo '</div>';
?>
</div>
Glad for all the help possible.
Cheers!