Hi all,
Basically I'm banging my head against the wall recently trying to get a list of checkboxes to pass variables to a SQL query. If the checkbox is ticked then I wish for the a certain SQL query to be passed. This is my code at the moment that I'm toying with:
<form method="POST" name="myform2" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<br>
Please enter a UserID to update with award icons:<br>
UserID: <input type="text" name="multiid"> <br>
<br>
Attack <input type="checkbox" onClick="document.myform2.a0.value = this.checked"><
Defence <input type="checkbox" onClick="document.myform2.b0.value = this.checked"><br>
<input type="hidden" name="b0" value="3">
Strength <input type="checkbox" onClick="document.myform2.c0.value = this.checked"><br>
<input type="hidden" name="c0" value="13">
HP <input type="checkbox" onClick="document.myform2.d0.value = this.checked"> <br>
<input type="hidden" name="d0" value="11">
Ranged <input type="checkbox" onClick="document.myform2.e0.value = this.checked"> <br>
<input type="hidden" name="e0" value="16">
Prayer <input type="checkbox" onClick="document.myform2.f0.value = this.checked"> <br>
<input type="hidden" name="f0" value="19">
Magic <input type="checkbox" onClick="document.myform2.g0.value = this.checked"> <br>
<input type="hidden" name="g0" value="12">
Cooking <input type="checkbox" onClick="document.myform2.h0.value = this.checked"> <br>
<input type="hidden" name="h0" value="1">
Woodcutting <input type="checkbox" onClick="document.myform2.i0.value = this.checked"> <br>
<input type="hidden" name="i0" value="21">
Fletching <input type="checkbox" onClick="document.myform2.j0.value = this.checked"> <br>
<input type="hidden" name="j0" value="4">
Fishing <input type="checkbox" onClick="document.myform2.k0.value = this.checked"> <br>
<input type="hidden" name="k0" value="9">
Firemaking <input type="checkbox" onClick="document.myform2.l0.value = this.checked"> <br>
<input type="hidden" name="l0" value="8">
Crafting <input type="checkbox" onClick="document.myform2.m0.value = this.checked"> <br>
<input type="hidden" name="m0" value="6">
Smithing <input type="checkbox" onClick="document.myform2.n0.value = this.checked"> <br>
<input type="hidden" name="n0" value="15">
Mining <input type="checkbox" onClick="document.myform2.o0.value = this.checked"> <br>
<input type="hidden" name="o0" value="14">
Herblore <input type="checkbox" onClick="document.myform2.p0.value = this.checked"> <br>
<input type="hidden" name="p0" value="10">
Agility <input type="checkbox" onClick="document.myform2.q0.value = this.checked"> <br>
<input type="hidden" name="q0" value="5">
Thieving <input type="checkbox" onClick="document.myform2.r0.value = this.checked"> <br>
<input type="hidden" name="r0" value="20">
Slayer <input type="checkbox" onClick="document.myform2.s0.value = this.checked"> <br>
<input type="hidden" name="s0" value="18">
Farming <input type="checkbox" onClick="document.myform2.t0.value = this.checked"> <br>
<input type="hidden" name="t0" value="7">
Runecraft <input type="checkbox" onClick="document.myform2.u0.value = this.checked"> <br>
<input type="hidden" name="u0" value="17">
Hunter <input type="checkbox" onClick="document.myform2.v0.value = this.checked"> <br>
<input type="hidden" name="v0" value="47">
Construction <input type="checkbox" onClick="document.myform2.w0.value = this.checked"> <br>
<input type="hidden" name="w0" value="50">
<br><br>
<input type="submit" name="Submit"> </form>
<?
$attack80 = $_POST['a0'];
$defence80 = $_POST['b0'];
$strength80 = $_POST['c0'];
$hp80 = $_POST['d0'];
$ranged80 = $_POST['e0'];
$prayer80 = $_POST['f0'];
$magic80 = $_POST['g0'];
$cooking80 = $_POST['h0'];
$woodcutting80 = $_POST['i0'];
$fletching80 = $_POST['j0'];
$fishing80 = $_POST['k0'];
$firemaking80 = $_POST['l0'];
$crafting80 = $_POST['m0'];
$smithing80 = $_POST['n0'];
$mining80 = $_POST['o0'];
$herblore80 = $_POST['p0'];
$agility80 = $_POST['q0'];
$thieving80 = $_POST['r0'];
$slayer80 = $_POST['s0'];
$farming80 = $_POST['t0'];
$runecraft80 = $_POST['u0'];
$hunter80 = $_POST['v0'];
$construction80 = $_POST['w0'];
$multiid = $_POST['multiid'];
if ($multiid = '')
{
echo "Please enter an userid";
}
else
{
if ($attack80 = '2')
{
echo "Yes this works";
$db->query_write("
INSERT INTO " . TABLE_PREFIX . "award_user
(award_id, userid, issue_reason, issue_time)
VALUES ('2', '$multiid', '" . addslashes($vbulletin->GPC['issue_reason']) . "', " . time() . ")
");
}
if ($defence80 = '3')
{
$db->query_write("
INSERT INTO " . TABLE_PREFIX . "award_user
(award_id, userid, issue_reason, issue_time)
VALUES ('3', '$multiid', '" . addslashes($vbulletin->GPC['issue_reason']) . "', " . time() . ")
");
}
}
Any help or assistance would be greatly appreciated with this as I have been pulling my hair out for the past week over this and different tutorials are not easy to comprehend with regards to checkbox values.
Kind Regards
JayJ
p.s. Good to see Daniweb going strong after all these years :)