View Full Version : need quick help!

03-03-2010, 03:26 PM
i am very new to php, and i am trying to put this code into a button.
I had posted yesterday about the code itself, but i have that now. i am just trying to put it into a button now. I obviously had help on the code, and im just trying to tailor this block of code for my specific field, so i can edit it and make it for the rest.

i have a db row displaying name & quantity, and i have a script that will -1 from the quanitity and post a message on another table - all from the click of a single button!... I just dont know how to assign it to the proper field so it -1's from that designated quanitity field.

My fields are:
etc... all the way to $$school10///$VL10.

Just do $VL1, so i can see how to do it for the rest.

the set up example:

<table width="566" border="1">
<td width="300">School name 1</td>
<td width="130"><label>
<input name="$VL1" type="text" id="$VL1" value="15" size="10" maxlength="10" />
<td width="114"><a href="-1 code">DEDUCT -1</a></td>
<td>School name 2</td>
<td><input name="$VL2" type="text" id="$VL2" value="13" size="10" maxlength="10" /></td>
<td><a href="-1 code">DEDUCT -1</a></td>

the code to run in each link, needs to be tailored to the $VL1


if ( isset($_GET['action'], $_GET['field']) && $_GET['action'] == 'subtract' ) {

$field = mysql_real_escape_string(urldecode($_GET['field']));

if ( !mysql_query("UPDATE virtual_left SET $field = $field - 1") ) {
echo "problem executing query: " . mysql_error() . "<p />";

if ( !mysql_query("INSERT INTO audit (message) VALUES ('school1 -1 apple')") ) {
echo "problem executing query: " . mysql_error() . "<p />";

// We are done, redirect..
header("Location: view.php");
} ?>

if someone can tailor that code for the first one ($vl1), and show me how to set up that form so it'll run correctly that would be great, and i can tailor each one to it after. i just need the first one set up to see how its done.

thanks in advance!
and goodmorning!

03-03-2010, 04:01 PM
Start with #2 from the forum guidelines (http://www.codingforums.com/postguide.htm):

2) Type in a subject that summarizes your question- A great way to turn off other members wanting to help you is to type an incomplete or silly subject for your post. Examples of poor subject titles include:

- "Help!"
- "I'm a newbie...be gentle"
- "How can I..."
- "Urgent...deadline tomorrow!"

The above subjects either have absolutely nothing to do with the question itself, or are grossly incomplete (ie: "How can I..."). When asking for help, enter a subject that summarizes your question, period! Don't use silly, incomplete, or "bait" subjects. Some examples of good titles are:

- "How do I round a number to 2 decimal places using JavaScript?"
- "What's the difference between require() and include() in PHP?"
- "Can someone suggest a good, free HTML editor?"