简体   繁体   中英

Jquery dialog confirmation to a specific a href link with php variable

I want to pop up a jquery confirmation dialog when i press to delete an item from my database, the code above is inside a while($records=mysql_fetch_aray) so i have several records:

echo"<tr>
    <td>".$registo["id_produto"]."</td>
    <td><img src='data:image/jpeg;base64,".base64_encode($registo["pic"])."' width='80' height='80'></td>
    <td>".$registo["nome"]."</td>
    <td>".$registo["preco"]."</td>
    <td>".$registo["quantidade"]."</td>
    <td>".$categoria."</td>
    <td>".$registo["descricao"]."</td>
    <td>".$registo["cura"]."</td>
    <td>".$registo["aroma"]."</td>
    <td><a href='deleteProduto.php?id={$registo["id_produto"]}'><i class='fa fa-times'></i> Delete</a></td>
    </tr>";

When i press the "delete" button i wanted to pop up a jquery confirmation dialog with a "yes" and "no" and when pressed yes go to "deleteProduto.php" with the respective id of the item i want to delete.

I've searched about this but only finded this working with a form and i only want it to work with the 'a href' link with the respective "id".

I wonder how your code is working at all without tons of warnings and errors.

I think you propably didnt notice it, because you did it correctly in the rest of the code but

"...?id={$registo["id_produto"]}'>...";

is definetely no proper string composing. It hast to be

"...?id=".$registo["id_produto"]."'>...";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM