Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8288631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:19:05+00:00 2026-06-08T12:19:05+00:00

I have a page where I list items ( in this case businesses) that

  • 0

I have a page where I list items ( in this case businesses) that are pulled from a mysql database with php.

<? 
    include('config.php');
    echo "<h3>Saved Businesses</h3>";
    echo "<ul style='list-style-type:none;'>";
    $result = mysql_query("SELECT * FROM `saved_biz` WHERE user_id = '$id'") or trigger_error(mysql_error()); 
    while($row = mysql_fetch_array($result)){

        foreach($row AS $key => $value) { $row[$key] = stripslashes($value); }
            $business_id = $row['business_id'];
            $result = mysql_query("SELECT * FROM `company` WHERE id = '$business_id'") or trigger_error(mysql_error());
            while($row = mysql_fetch_array($result)){
                $business_name = $row['name'];
            }
        echo "<li>" . nl2br( $business_name);  
        echo "<a href=deletesavedbiz.php?id={$row['id']}>Delete</a></li>"; 
        echo "</tr>"; 
    } 
    echo "</ul>"; 
?>

If the user decides to delete one of the businesses ( by clicking the “Delete” link ) he/she is then taken to deletesavedbiz.php and then, if successful, presented with a link to get back to the profile.php page that he/she was just on.

<? 
    include('config.php'); 
    $id = (int) $_GET['id']; 
    mysql_query("DELETE FROM `saved_biz` WHERE `id` = '$id' ") ; 
    echo (mysql_affected_rows()) ? "Row deleted.<br /> " : "Nothing deleted.<br /> "; 
?> 

<a href='profile.php'>Back To Listing</a>

Now, what I want to do is have the php delete and then do like a php header redirect to profile.php without ever making the user click a link back. How can I accomplish this? Also, I’m fine with having the answer being javascript if it’s not possible or not very clean in PHP.

Thanks for all help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:19:06+00:00Added an answer on June 8, 2026 at 12:19 pm

    Do redirect in case your query returned TRUE.

    function redirect($page = 'profile.php'){
     header("Location: $page");
     exit;
    }
    
    
    function your_query(){
        include('config.php');
        $id = (int) $_GET['id']; 
        //returns TRUE on success, FALSE otherwise
        return mysql_query("DELETE FROM `saved_biz` WHERE `id` = '$id' ") ; 
    }
    
    
    if ( your_query() ){
      redirerct();
    } else {
      redirect('some_error_page.php');
    }
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page with a list of items initially loaded from a include_once('show_calendarV2.php');
I have a page ItemList that shows a list of items using div's. After
I have a list of items on my web page that the user can
I have a page with a list of lot of Products from the database.
I have a case that I have a list page which list all the
I have a page with a list of elements display (items) - which are
I have a list of items on a page with a set of controls
I have several ReorderLists on a page. Each list has items added to it
I have a page which list comments of users. My problem is that I
I have this binding on my page. The page shows a table of items.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.