I'm trying to display the details of projects in database and and allow admins to them delete them.
Here's what I have so far:
<?php
include 'dbc.php';
$query=mysql_query("select * from pro1");
while($result=mysql_fetch_array($query)){
echo '<span>'.$result['name'].'</span>'.'<a href="#" id='.$result['pro_id'].' onclick="delet(this.id);">delet</a>'.'<br/>';
}
?>
<html>
<head>
</head>
<body>
<span>test10</span><a href="#" id=10 onclick="delet(this.id);">delet</a>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
function delete(proid){
//alert(proid);
$.post("back.php",{
proid:proid
},function(data){
alert(data);
});
});//ready func end
</script>
</body>
</html>
I'm getting the proid
from db... now I need to send the id with ajax.
The loop output will be something like this:
<span>test10</span>
<a href="#" id=10 onclick="delete(this.id);">delete</a>