0
Good afternoon, I have the following code:
<?php
$list = $conn->prepare("SELECT * FROM produtos");
$list->execute();
echo '<div id="pd_list">';
echo '<div class="head">';
echo '<p class="title" style="margin-top:8px; margin-left:5px; float:left; width:800px; margin-bottom:3px;">Produtos</p>';
echo '<form>';
echo '<input type="text">';
echo '<button><img src="../image/lupa.png" width="24"></button>';
echo '</form>';
echo '</div>';
echo '<div id="items">';
foreach($list as $result):
echo '<div id="item">';
if($result['img'] != null){
echo '<img src="../uploads/produtos/'.$result['img'].'" width="215">';
}else{
echo '<img src="../image/fundo-produto.jpg" width="215">';
}
echo '<p style="margin-bottom:4px; float:left; margin-left:5px; padding-left:5px; padding-right:5px; text-align:center; text-transform: uppercase; width:215px; height:40px;">'.$result['nome'].'</p>';
echo '<p style="margin-top:0px; margin-bottom:4px; float:left; margin-left:5px; padding-left:5px; padding-right:5px; text-align:center; width:215px; font-size:20px;">R$ '.$result['valor'].'</p>';
echo '<div class="opc">';
echo '<button id="link-excluir" class="ui-button ui-corner-all ui-widget">';
echo '<span class="ui-icon ui-icon-newwin"></span>';
echo '</button>';
echo '<div id="excluir">';
echo '<p>Deseja Excluir?</p>';
echo '</div>';
echo '</div>';
echo '</div>';
endforeach;
echo '</div>';
echo '<div class="holder"></div>';
echo '</div>';
?>
with the following jQuery code, using jQuery-ui Dialog:
<script>
$(document).ready(function() {
var opt = {
autoOpen: false,
modal: true,
width: 550,
height:350,
title: 'Excluir'
};
$( "#excluir" ).dialog(opt);
$( "#link-excluir" ).click(function( event ) {
$( "#excluir" ).dialog(opt).dialog( "open" );
event.preventDefault();
});
$( "#link-excluir, #icons li" ).hover(
function() {
$( this ).addClass( "ui-state-hover" );
},
function() {
$( this ).removeClass( "ui-state-hover" );
}
);
});
</script>
there as you can see using foreach to display all my results, and I want to use Dialog to open a box for deletion, the Dialog is working perfectly, however it only works in the first item, the others is not right, and I want to pass the item id by it to work with it within Dialog, whether to delete or edit, how can I do that? as you can see the Dialog div is inside the foreach. BS: I am very JS layman