KirstyScott Posted January 9, 2009 Share Posted January 9, 2009 Hi all Is it possible to make a db update when someone clicks a link, if so how would i go about doing this? and if possible, make it once every 12 hours or day? ??? Quote Link to comment https://forums.phpfreaks.com/topic/140105-how-to/ Share on other sites More sharing options...
darkfreaks Posted January 9, 2009 Share Posted January 9, 2009 <?php function delete_db($delete){ $delete="DELETE whatever FROM table WHERE value='$value'"; $result=mysql_query($delete) or die(mysql_error()); if($result){ return $result; } } echo '<a href=mysite.com/page.php?action="'.delete_db.'" target=_blank>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/140105-how-to/#findComment-733053 Share on other sites More sharing options...
Maq Posted January 9, 2009 Share Posted January 9, 2009 You make a link with the $_GET method and wherever you process it, you just call that variable in the SQL statement. You can use a cron job to run a script either every 12 hours or 1 day. Can you be a little more specific? Quote Link to comment https://forums.phpfreaks.com/topic/140105-how-to/#findComment-733054 Share on other sites More sharing options...
darkfreaks Posted January 9, 2009 Share Posted January 9, 2009 or use a link to pass a function like i did above that deletes something when clicked or updates Quote Link to comment https://forums.phpfreaks.com/topic/140105-how-to/#findComment-733055 Share on other sites More sharing options...
trq Posted January 9, 2009 Share Posted January 9, 2009 or use a link to pass a function like i did above that deletes something when clicked or updates Um, your code does nothing at all, sorry. Quote Link to comment https://forums.phpfreaks.com/topic/140105-how-to/#findComment-733121 Share on other sites More sharing options...
KirstyScott Posted January 9, 2009 Author Share Posted January 9, 2009 TY darkfreaks! but i tried that and it dosen't do the thing i asked, ty for trying though Still need help on this one guys Quote Link to comment https://forums.phpfreaks.com/topic/140105-how-to/#findComment-733125 Share on other sites More sharing options...
gevans Posted January 9, 2009 Share Posted January 9, 2009 Show us some code and we'll fix it for you, it's a relatively simple task Quote Link to comment https://forums.phpfreaks.com/topic/140105-how-to/#findComment-733187 Share on other sites More sharing options...
KirstyScott Posted January 9, 2009 Author Share Posted January 9, 2009 I don't have a code yet, i was just asking if it was possible and if so how would i go about it, i tried the code posted first, but that updates the table before they click the link :-\ So is it possible if someone clicks a link and as soon as they click the link, a table gets updated? and how would i go about this? :-X Quote Link to comment https://forums.phpfreaks.com/topic/140105-how-to/#findComment-733741 Share on other sites More sharing options...
trq Posted January 10, 2009 Share Posted January 10, 2009 if (isset($_GET['action'])) { if ($_GET['action'] == 'update') { // execute your query here. } } echo "<a href='?action=update'>update</a>"; Quote Link to comment https://forums.phpfreaks.com/topic/140105-how-to/#findComment-733770 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.