By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,304 Members | 1,242 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,304 IT Pros & Developers. It's quick & easy.

formula in subtracting a formula in php with mysql

P: 3
hi all, i have problem in creating a formula of my code. this is all about updating a mysql database in including it in php. I dont know how to generate it. can you please give me some code in a working php with mysql.

This code is to update after clicking the word update and to subtract each time to click by once..

Please help me..

Sample code:
"SELECT * FROM tablename WHERE time = 20";
$time1 = time -1 ;
"UPDATE tablename SET time = $time1";

Is this correct?

What else would i add to make my code complete in updating my mysql database?
Feb 22 '08 #1
Share this Question
Share on Google+
1 Reply


P: 5
hi all, i have problem in creating a formula of my code. this is all about updating a mysql database in including it in php. I dont know how to generate it. can you please give me some code in a working php with mysql.

This code is to update after clicking the word update and to subtract each time to click by once..

Please help me..

Sample code:
"SELECT * FROM tablename WHERE time = 20";
$time1 = time -1 ;
"UPDATE tablename SET time = $time1";

Is this correct?

What else would i add to make my code complete in updating my mysql database?
that would be something like this if i understood what you mean:

[PHP]
<?php
if($_GET['update'] == 1) {
$sql = mysql_query("UPDATE `tablename` SET time='".$time1."'");
if(!$sql){die ("Error: ".mysql_error()."");}
echo "Update successful!";
}

echo "<a href=\"?update=1\">Update!</a>";
?>
[/PHP]
Feb 22 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.