View Single Post
  #1 (permalink)  
Old 10-29-03, 12:03 PM
DisneyFan25863 DisneyFan25863 is offline
New Member
 
Join Date: Oct 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
PHP to MySQL script question...(using a field to update info in MySQL)

Ok, I've been thinking about how to do this for some time, but can't figure it out. I basically want to have a number stored in a MySQL Database, which can be added or subtracted to from a webpage, then displayed on another. So Basically, the script would be like this. I would put in a query string for each number, (like www.whatever.com/number.php?changenumber=yes, but I already know how to do that). I would then have it so that there would be an option with two buttons (one that says add, one that says subtract), and then a text field for a number. So, for instance, if I wanted to subtract 4 , it would go like this:

I would select the button for "subtract" on the form, then enter "4" in the text field. Clicking submit would go to a php script that would put it in a database. This is where I need help. What should I put for the script?
Something like this?


PHP Code:

<?php

$conn 
mysql_connect("localhost""user""pass");
mysql_select_db("DB",$conn);
$sql "INSERT INTO Table values ('', 'What to put here?')";
if (
mysql_query($sql$conn)) {
     echo 
"record added!";
} else {
    echo 
"something went wrong";
}
?>

If I were to just use a "$_POST[field]')" there, it would replace the number, right? So does anyone know what I should put?

Thank You!
Reply With Quote