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
[IMG]http://i67.tinypic.com/1zqczvd.png[/IMG]

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;\">

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.