Dear Experts, I have following codes

while($res = mysqli_fetch_array($result)) {         
        echo "<tr onMouseOver=this.className='highlight' onMouseOut=this.className='normal'>";
        echo "<td align='center' width='10%' >".$res['code']."</td>";
        echo "<td align='left' width='50%' >".$res['products']."</td>";
        echo "<td align='center' width='20%'>".$res['weight']."</td>";    
        echo "<td align='center' width='20%' ><a href=\"master_u.php?id=$res[id]\"><img src=images/pencil.png alt=Edit title=Edit></a>  <a href=\"delete.php?id=$res[id]\" onClick=\"return confirm('Are you sure you want to delete?')\"><img src=images/delete16.png alt=Delete title=Delete></a></td></tr>";

the codes create this result

The problem is when I press Delete icon then it ask
Are you sure you want to delete?
when I press yes then recored is deleted successfully but....
page redirects to someother page, why?

I want the page must not redirect to any other page.

Please help

You have an href set for the <a> tag so after the onclick is processed the anchor does what it is meanrt to do. To prevent it firing change your onclick to:
onClick=\"confirm('Are you sure you want to delete?'); return false;\">