Hello all,

I'm want to do a PHP redirect within a <DIV>.

Currently I have written the folowing code, that allows a database entry to be selected and be deleted.

<?php 
//This is from a file named delete.php
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);

      if(isset($_POST['delete'])) {
   
      foreach($_POST['checkbox'] as $id){
   
      mysql_query("DELETE from $tbl_name WHERE id =$id LIMIT 1");
   }
      
    }

if($result){


[B]echo "<meta http-equiv=\"refresh\" content=\"0;URL=viewdiary.php\">";[/B]

}
?>

I have highlighted the code that redirects from the delete.php to the page viewdiary.php.

What I want to accomplish is let this run in a div.

Note that my div id is the following

<div id='news1'>

I am using the following jquery statement.

<a href="#" onclick="ajax_loadContent('news1','index.php');return false">My Diary</a>

This works fine and to elaborate it allows me to load content into a <DIV> area, but obviousy I need to incorporate this into the above mentioned code.

Please help and thank you in advance.

Rosekrans

echo "<script type='text/javascript>window.location.href='http://www.example.com/';</script>";

Thnx for the reply. This script only takes me to a new page. As stated I want it to load within a div. Is there someway to use the div id within the link?

how about

echo "<script type='text/javascript>ajax_loadContent('news1','index.php');</script>";

?

I think i tried the above myself one time and it didnt work. hence i do this below

You can get the page to return code eg.

if($success){
echo "Y";
}else{
echo "N";
}

Then on the ajax:

if(responseText == 'Y'){
otherJSFunction();
}else{
anotherJSFunction();
}

That way you are still on the javascript of the main page and can change the content of the div still.

I'll try this new method. I wil post my findings tomorrow.

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.