/    Sign up×
Community /Pin to ProfileBookmark

Update database

Can anyone help me get this to work ? I need it to update the table if a person clicks cancel only. I do not know javascript and I been trying to read up this today and I got this far, but not working.

[code=php]
<SCRIPT LANGUAGE=”JavaScript”>
function leave() {

if(confirm(“Yes ? – Press OK. Or No ? – Press Cancel”)) {
}
else {
$query=”update url set status=’0′ where id=’$urlid'”;
mysql_query($query) or die( “ERROR: ” . mysql_error() . “n”);
}
}
</SCRIPT>
[/code]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@pj59Jan 04.2005 — You should have a form in the file with the javascript with an action that executes a php script on the server doing the update job. The part in your code snippet which is php right now simply would have to be substituted by js code submitting that form. You cannot execute php code on the client side but that is what you attempt to do.

Another way would be to do a redirect to the file with the php script when the user clicks cancel.

The information you provided is not sufficient to go deeper now.

PJ
Copy linkTweet thisAlerts:
@slimjimauthorJan 04.2005 — I did the redirect and i was able to change variables in url thru url and change other rows. SO that actually didnt work for me.

i did this below instead of the update in javascript and redirected to this page below, but like i said, did work, but was able to change info in url and change other rows in database.

[code=php]
window.open("popuptest.php?user=<? echo $username; ?>&url=<? echo $url; ?>");
[/code]
×

Success!

Help @slimjim spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...