Page 1 of 1

Update query requires confirmaton before executing. HOW?

Posted: Thu Nov 17, 2005 7:32 am
by besbajah
Hi,

Sorry to be such a nerd on this one, and bear with me, I do have some programming experience - just obviously not enough.

I have an update query as follows: - hardly, woooo, complicated!!!

Code: Select all

$result = mysql_db_query("vinylsur_music", "UPDATE Music SET Rank = Rank + 0.1 WHERE Track='test' AND Artist ='test'");
It simply adds a score of 0.1 to the existing Rank field depending on the clause, and as I told you, it's hardly complicated.

But, and this is the big bottom, I need some way of confirming the update before the query submits the data, otherwise you open the webpage and the update submits the value - not very good. I would like to use an array and while loop at a later date, but hey, don't get frazzled trying to explain that, don't worry.

Please brothers, help me with a way of confirming this query before it submits. To re-cap, I've got the $result variable with the value of the query in it, but I want to hold that value in the variable until a click on a button or link is made. I've tried using Forms but it's too complicated for me.

Where do I go?

Mas se lembra, não esquenta a cabeça!

Bes.

Posted: Thu Nov 17, 2005 7:46 am
by Grim...
Why not use something like

Code: Select all

<a href="addpointspage.php" onclick="return confirm('Are you sure?');">
And then on addpointspage.php:

Code: Select all

$result = mysql_db_query("vinylsur_music", "UPDATE Music SET Rank = Rank + 0.1 WHERE Track='test' AND Artist ='test'"); 

header("location: someotherpage.php");
exit;

Posted: Thu Nov 17, 2005 9:36 am
by twigletmac
Note that the mysql_db_query() function has been deprecated since PHP 4.0.6 - so instead of:

Code: Select all

$result = mysql_db_query("vinylsur_music", "UPDATE Music SET Rank = Rank + 0.1 WHERE Track='test' AND Artist ='test'");
you should have

Code: Select all

mysql_select_db('vinylsur_music');

$result = mysql_query("UPDATE Music SET Rank = Rank + 0.1 WHERE Track='test' AND Artist ='test'");
Mac