1337hovie
03-03-2010, 02: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.
script:
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:
$school1/////$VL1
$school2/////$VL2
$school3////$VL3
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">
<tr>
<td width="300">School name 1</td>
<td width="130"><label>
<input name="$VL1" type="text" id="$VL1" value="15" size="10" maxlength="10" />
</label></td>
<td width="114"><a href="-1 code">DEDUCT -1</a></td>
</tr>
<tr>
<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>
</tr>
</table>
the code to run in each link, needs to be tailored to the $VL1
<?php
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!
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.
script:
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:
$school1/////$VL1
$school2/////$VL2
$school3////$VL3
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">
<tr>
<td width="300">School name 1</td>
<td width="130"><label>
<input name="$VL1" type="text" id="$VL1" value="15" size="10" maxlength="10" />
</label></td>
<td width="114"><a href="-1 code">DEDUCT -1</a></td>
</tr>
<tr>
<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>
</tr>
</table>
the code to run in each link, needs to be tailored to the $VL1
<?php
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!