Jump to content

[SOLVED] cache problem


digitalgod

Recommended Posts

hey guys,

 

I have a script where users can add/remove clients, my problem is that when a person clicks on delete, the page refreshes, the row gets deleted from the db but it still shows that client in the html table, the info will disappear only after a page refresh.

 

I'm pretty sure it's a cache problem but I have no idea how to fix this..

 

any suggestions would be greatly appreciated!

Link to comment
https://forums.phpfreaks.com/topic/119331-solved-cache-problem/
Share on other sites

I doubt its a cache problem. What i can think is that your update code is procedurally below the fetch code. Smth like this:

 

query the db and show info

.....

delete handler

 

where it should be

 

delete handler

....

query the db and show info

 

That way u update the db and then show the information. Hope this helped.

Link to comment
https://forums.phpfreaks.com/topic/119331-solved-cache-problem/#findComment-614784
Share on other sites

hmm I see what you mean, makes perfect sense.

 

here's what I've been doing

 

$sql_clients = "SELECT * FROM client";
$result = mysql_query($sql_clients);
$clients_count = mysql_num_rows($result);

if( isset($_GET['a'])  && isset($_GET['id']))
{
        $action = stripslashes(mysql_real_escape_string($_GET['a']));

        if ( $action == "del" )
        {
       $cid = stripslashes(mysql_real_escape_string($_GET['id']));
       $sql_delete = "DELETE FROM client WHERE client_id = '$cid'";
       $delete_result = mysql_query($sql_delete);
       $sql_delete2 = "DELETE FROM client_address WHERE client_id = '$cid'";
       $delete_result2 = mysql_query($sql_delete2);
        }
}

 

so I guess I should just switch them around instead.

 

edit

works perfectly, thanks!

Link to comment
https://forums.phpfreaks.com/topic/119331-solved-cache-problem/#findComment-615245
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.